fn channel_select(mut channels []&Channel, dir []Direction, mut objrefs []voidptr, timeout time.Duration) int
Wait timeout
on any of channels[i]
until one of them can push (is_push[i] = true
) or pop (is_push[i] = false
) object referenced by objrefs[i]
. timeout < 0
means wait unlimited time. timeout == 0
means return immediately if no transaction can be performed without waiting. return value: the index of the channel on which a transaction has taken place -1 if waiting for a transaction has exceeded timeout -2 if all channels are closed
fn new_channel<T>(n u32) &Channel
fn new_mutex() &Mutex
fn new_rwmutex() &RwMutex
fn new_semaphore() &Semaphore
fn new_semaphore_init(n u32) &Semaphore
fn new_waitgroup() &WaitGroup
fn (mut ch Channel) close()
fn (mut ch Channel) len() int
fn (mut ch Channel) closed() bool
fn (mut ch Channel) push(src voidptr)
fn (mut ch Channel) try_push(src voidptr) ChanState
fn (mut ch Channel) pop(dest voidptr) bool
fn (mut ch Channel) try_pop(dest voidptr) ChanState
fn (mut sem Semaphore) init(n u32)
fn (mut sem Semaphore) post()
fn (mut sem Semaphore) wait()
fn (mut sem Semaphore) try_wait() bool
fn (mut sem Semaphore) timed_wait(timeout time.Duration) bool
fn (sem Semaphore) destroy() bool
fn (mut wg WaitGroup) init()
fn (mut wg WaitGroup) add(delta int)
add increments (+ve delta) or decrements (-ve delta) task count by delta and unblocks any wait() calls if task count becomes zero. add panics if task count drops below zero.
fn (mut wg WaitGroup) done()
done is a convenience fn for add(-1)
fn (mut wg WaitGroup) wait()
wait blocks until all tasks are done (task count becomes zero)
struct Mutex {
mutex C.pthread_mutex_t
}
fn (mut m Mutex) init()
fn (mut m Mutex) @lock()
@lock(), for manual mutex handling, since lock
is a keyword
fn (mut m Mutex) unlock()
struct RwMutex {
mutex C.pthread_rwlock_t
}
fn (mut m RwMutex) init()
fn (mut m RwMutex) @rlock()
RwMutex has separate read- and write locks
fn (mut m RwMutex) @lock()
fn (mut m RwMutex) runlock()
Windows SRWLocks have different function to unlock So provide two functions here, too, to have a common interface
fn (mut m RwMutex) unlock()