mirror of
https://codeberg.org/superseriousbusiness/gotosocial.git
synced 2024-12-24 01:48:16 +03:00
7cc40302a5
* add miekg/dns dependency * set/validate accountDomain * move finger to dereferencer * totally break GetRemoteAccount * start reworking finger func a bit * start reworking getRemoteAccount a bit * move mention parts to namestring * rework webfingerget * use util function to extract webfinger parts * use accountDomain * rework finger again, final form * just a real nasty commit, the worst * remove refresh from account * use new ASRepToAccount signature * fix incorrect debug call * fix for new getRemoteAccount * rework GetRemoteAccount * start updating tests to remove repetition * break a lot of tests Move shared test logic into the testrig, rather than having it scattered all over the place. This allows us to just mock the transport controller once, and have all tests use it (unless they need not to for some other reason). * fix up tests to use main mock httpclient * webfinger only if necessary * cheeky linting with the lads * update mentionName regex recognize instance accounts * don't finger instance accounts * test webfinger part extraction * increase default worker count to 4 per cpu * don't repeat regex parsing * final search for discovered accountDomain * be more permissive in namestring lookup * add more extraction tests * simplify GetParseMentionFunc * skip long search if local account * fix broken test * consolidate to all use same caching libraries Signed-off-by: kim <grufwub@gmail.com> * perform more caching in the database layer Signed-off-by: kim <grufwub@gmail.com> * remove ASNote cache Signed-off-by: kim <grufwub@gmail.com> * update cache library, improve db tracing hooks Signed-off-by: kim <grufwub@gmail.com> * return ErrNoEntries if no account status IDs found, small formatting changes Signed-off-by: kim <grufwub@gmail.com> * fix tests, thanks tobi! Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
69 lines
2.2 KiB
Go
69 lines
2.2 KiB
Go
package atomics
|
|
|
|
import "sync/atomic"
|
|
|
|
// Int32 provides user-friendly means of performing atomic operations on int32 types.
|
|
type Int32 int32
|
|
|
|
// NewInt32 will return a new Int32 instance initialized with zero value.
|
|
func NewInt32() *Int32 {
|
|
return new(Int32)
|
|
}
|
|
|
|
// Add will atomically add int32 delta to value in address contained within i, returning new value.
|
|
func (i *Int32) Add(delta int32) int32 {
|
|
return atomic.AddInt32((*int32)(i), delta)
|
|
}
|
|
|
|
// Store will atomically store int32 value in address contained within i.
|
|
func (i *Int32) Store(val int32) {
|
|
atomic.StoreInt32((*int32)(i), val)
|
|
}
|
|
|
|
// Load will atomically load int32 value at address contained within i.
|
|
func (i *Int32) Load() int32 {
|
|
return atomic.LoadInt32((*int32)(i))
|
|
}
|
|
|
|
// CAS performs a compare-and-swap for a(n) int32 value at address contained within i.
|
|
func (i *Int32) CAS(cmp, swp int32) bool {
|
|
return atomic.CompareAndSwapInt32((*int32)(i), cmp, swp)
|
|
}
|
|
|
|
// Swap atomically stores new int32 value into address contained within i, and returns previous value.
|
|
func (i *Int32) Swap(swp int32) int32 {
|
|
return atomic.SwapInt32((*int32)(i), swp)
|
|
}
|
|
|
|
// Int64 provides user-friendly means of performing atomic operations on int64 types.
|
|
type Int64 int64
|
|
|
|
// NewInt64 will return a new Int64 instance initialized with zero value.
|
|
func NewInt64() *Int64 {
|
|
return new(Int64)
|
|
}
|
|
|
|
// Add will atomically add int64 delta to value in address contained within i, returning new value.
|
|
func (i *Int64) Add(delta int64) int64 {
|
|
return atomic.AddInt64((*int64)(i), delta)
|
|
}
|
|
|
|
// Store will atomically store int64 value in address contained within i.
|
|
func (i *Int64) Store(val int64) {
|
|
atomic.StoreInt64((*int64)(i), val)
|
|
}
|
|
|
|
// Load will atomically load int64 value at address contained within i.
|
|
func (i *Int64) Load() int64 {
|
|
return atomic.LoadInt64((*int64)(i))
|
|
}
|
|
|
|
// CAS performs a compare-and-swap for a(n) int64 value at address contained within i.
|
|
func (i *Int64) CAS(cmp, swp int64) bool {
|
|
return atomic.CompareAndSwapInt64((*int64)(i), cmp, swp)
|
|
}
|
|
|
|
// Swap atomically stores new int64 value into address contained within i, and returns previous value.
|
|
func (i *Int64) Swap(swp int64) int64 {
|
|
return atomic.SwapInt64((*int64)(i), swp)
|
|
}
|