struct Mutex
pub struct Mutex {
pub tok chan int
}Purpose
Structure encapsulating tok.
Public fields
tokchan int- field (channel; type chan int)
#syncMutex / WaitGroup / Once / RWMutex / Cond and atomic int.
struct Mutexpub struct Mutex {
pub tok chan int
}Structure encapsulating tok.
tok chan intstruct WaitGrouppub struct WaitGroup {
}WaitGroup context or state structure.
This type has no public fields.
mutexpub fn mutex() MutexConstruct a mutual exclusion lock synchronization primitive.
No arguments are required.
Mutex — a value of this type
($&Mutex) lockpub fn (m $&Mutex) lock()Operation on $&Mutex: acquire the lock.
m $&MutexMutex instance used by this call (exclusive borrow).This call does not return a value.
($&Mutex) unlockpub fn (m $&Mutex) unlock()Operation on $&Mutex: release the lock.
m $&MutexMutex instance used by this call (exclusive borrow).This call does not return a value.
wait_grouppub fn wait_group() WaitGroupWait group.
No arguments are required.
WaitGroup — a value of this type
($&WaitGroup) addpub fn (w $&WaitGroup) add(delta int)Operation on $&WaitGroup: add.
w $&WaitGroupWaitGroup instance used by this call (exclusive borrow).delta intThis call does not return a value.
($&WaitGroup) donepub fn (w $&WaitGroup) done()Execute done on $&WaitGroup.
w $&WaitGroupWaitGroup instance used by this call (exclusive borrow).This call does not return a value.
($&WaitGroup) waitpub fn (w $&WaitGroup) wait(n int)Execute wait on $&WaitGroup.
w $&WaitGroupWaitGroup instance used by this call (exclusive borrow).n intThis call does not return a value.
($&WaitGroup) wait_pendingpub fn (w $&WaitGroup) wait_pending()Operation on $&WaitGroup: wait pending.
w $&WaitGroupWaitGroup instance used by this call (exclusive borrow).This call does not return a value.
load_intpub fn load_int(x $&int) intLoad int.
x $&intint — a value of this type
store_intpub fn store_int(x $&int, v int)Store int.
x $&intv intThis call does not return a value.
add_intpub fn add_int(x $&int, d int) intAdd int.
x $&intd intint — a value of this type
compare_and_swap_intpub fn compare_and_swap_int(x $&int, old int, new int) boolCompare and swap int.
x $&intold intnew intbool — true or false
struct Oncepub struct Once {
pub mu Mutex
}Structure encapsulating mu.
mu Mutexoncepub fn once() OnceExecute once.
No arguments are required.
Once — a value of this type
($&Once) first_timepub fn (o $&Once) first_time() boolOperation on $&Once: first time.
o $&OnceOnce instance used by this call (exclusive borrow).bool — true or false
($&Once) dopub fn (o $&Once) do(f fn())Execute do on $&Once.
o $&OnceOnce instance used by this call (exclusive borrow).f fn()fn(); pass the function value for this operation to invoke.This call does not return a value.
struct RWMutexpub struct RWMutex {
pub w Mutex
pub writer_sem chan int
pub reader_sem chan int
}Structure encapsulating w, writer_sem, reader_sem.
w Mutexwriter_sem chan intreader_sem chan intrw_mutexpub fn rw_mutex() RWMutexConstruct a new RWMutex.
No arguments are required.
RWMutex — a value of this type
($&RWMutex) closepub fn (m $&RWMutex) close()Operation on $&RWMutex: close the resource.
m $&RWMutexRWMutex instance used by this call (exclusive borrow).This call does not return a value.
($&RWMutex) read_lockpub fn (m $&RWMutex) read_lock()Operation on $&RWMutex: acquire a shared read lock.
m $&RWMutexRWMutex instance used by this call (exclusive borrow).This call does not return a value.
($&RWMutex) read_unlockpub fn (m $&RWMutex) read_unlock()Operation on $&RWMutex: release a read lock.
m $&RWMutexRWMutex instance used by this call (exclusive borrow).This call does not return a value.
($&RWMutex) write_lockpub fn (m $&RWMutex) write_lock()Operation on $&RWMutex: acquire an exclusive write lock.
m $&RWMutexRWMutex instance used by this call (exclusive borrow).This call does not return a value.
($&RWMutex) write_unlockpub fn (m $&RWMutex) write_unlock()Operation on $&RWMutex: release a write lock.
m $&RWMutexRWMutex instance used by this call (exclusive borrow).This call does not return a value.
struct CondStatepub struct CondState {
pub waiters []chan int
pub head int
}Structure encapsulating waiters, head.
waiters []chan inthead intstruct Condpub struct Cond {
pub state chan CondState
}Structure encapsulating state.
state chan CondStatecondpub fn cond() CondExecute cond.
No arguments are required.
Cond — a value of this type
($&Cond) waitpub fn (c $&Cond) wait(m $&Mutex)Execute wait on $&Cond.
c $&CondCond instance used by this call (exclusive borrow).m $&MutexThis call does not return a value.
($&Cond) signalpub fn (c $&Cond) signal()Execute signal on $&Cond.
c $&CondCond instance used by this call (exclusive borrow).This call does not return a value.
($&Cond) broadcastpub fn (c $&Cond) broadcast()Execute broadcast on $&Cond.
c $&CondCond instance used by this call (exclusive borrow).This call does not return a value.
struct MapValpub struct MapVal {
pub value string
pub found bool
}Structure encapsulating value, found.
value stringfound boolstruct MapEntrypub struct MapEntry {
pub key string
pub val string
pub active bool
}Structure encapsulating key, val, active.
key stringval stringactive boolstruct Mappub struct Map {
pub mu RWMutex
}Structure encapsulating mu.
mu RWMutexsync_mappub fn sync_map() MapSync map.
No arguments are required.
Map — a value of this type
($&Map) closepub fn (m $&Map) close()Operation on $&Map: close the resource.
m $&MapMap instance used by this call (exclusive borrow).This call does not return a value.
($&Map) loadpub fn (m $&Map) load(key &string) MapValExecute load on $&Map.
m $&MapMap instance used by this call (exclusive borrow).key &stringMapVal — a value of this type
($&Map) storepub fn (m $&Map) store(key string, val string)Execute store on $&Map.
m $&MapMap instance used by this call (exclusive borrow).key stringval stringThis call does not return a value.
($&Map) deletepub fn (m $&Map) delete(key &string)Execute delete on $&Map.
m $&MapMap instance used by this call (exclusive borrow).key &stringThis call does not return a value.
($&Map) load_or_storepub fn (m $&Map) load_or_store(key string, val string) MapValOperation on $&Map: load or store.
m $&MapMap instance used by this call (exclusive borrow).key stringval stringMapVal — a value of this type
($&Map) load_and_deletepub fn (m $&Map) load_and_delete(key &string) MapValOperation on $&Map: load and delete.
m $&MapMap instance used by this call (exclusive borrow).key &stringMapVal — a value of this type
($&Map) lenpub fn (m $&Map) len() intOperation on $&Map: return the length.
m $&MapMap instance used by this call (exclusive borrow).int — a value of this type
struct Poolpub struct Pool {
pub ch chan string
}Sync Connection pool manager scheduling reusable socket connections.
ch chan stringpoolpub fn pool(capacity int) PoolExecute pool.
capacity intPool — a value of this type
(&Pool) putpub fn (p &Pool) put(val string)Store or update the value associated with the specified key.
p &PoolPool instance used by this call (borrow).val stringThis call does not return a value.
(&Pool) getpub fn (p &Pool) get() MapValExecute get on &Pool.
p &PoolPool instance used by this call (borrow).MapVal — a value of this type