Documentation
¶
Overview ¶
Package threads provides SRFI-18 multithreading primitives.
Threads ¶
- make-thread, thread?
- thread-name, thread-specific, thread-specific-set!
- thread-start!, thread-yield!, thread-sleep!
- thread-terminate!, thread-join!
- current-thread
Mutexes ¶
- make-mutex, mutex?
- mutex-name, mutex-specific, mutex-specific-set!
- mutex-state
- mutex-lock!, mutex-unlock!
Condition Variables ¶
- make-condition-variable, condition-variable?
- condition-variable-name
- condition-variable-specific, condition-variable-specific-set!
- condition-variable-signal!, condition-variable-broadcast!
Time ¶
- current-time, time?, time->seconds, seconds->time
Exceptions ¶
- join-timeout-exception?, abandoned-mutex-exception?
- terminated-thread-exception?, uncaught-exception?
- uncaught-exception-reason
Use Extension or AddToRegistry to register all primitives.
Package threads provides SRFI-18 threading primitives.
Index ¶
- Variables
- func PrimConditionVariableBroadcast(mc machine.CallContext) error
- func PrimConditionVariableName(mc machine.CallContext) error
- func PrimConditionVariableSignal(mc machine.CallContext) error
- func PrimConditionVariableSpecific(mc machine.CallContext) error
- func PrimConditionVariableSpecificSet(mc machine.CallContext) error
- func PrimCurrentThread(mc machine.CallContext) error
- func PrimCurrentTime(mc machine.CallContext) error
- func PrimMakeConditionVariable(mc machine.CallContext) error
- func PrimMakeMutex(mc machine.CallContext) error
- func PrimMakeThread(cc machine.CallContext) error
- func PrimMutexLock(mc machine.CallContext) error
- func PrimMutexName(mc machine.CallContext) error
- func PrimMutexSpecific(mc machine.CallContext) error
- func PrimMutexSpecificSet(mc machine.CallContext) error
- func PrimMutexState(mc machine.CallContext) error
- func PrimMutexUnlock(mc machine.CallContext) error
- func PrimSecondsToTime(mc machine.CallContext) error
- func PrimThreadJoin(mc machine.CallContext) error
- func PrimThreadName(mc machine.CallContext) error
- func PrimThreadSleep(mc machine.CallContext) error
- func PrimThreadSpecific(mc machine.CallContext) error
- func PrimThreadSpecificSet(mc machine.CallContext) error
- func PrimThreadStart(mc machine.CallContext) error
- func PrimThreadTerminate(mc machine.CallContext) error
- func PrimThreadYield(mc machine.CallContext) error
- func PrimTimeToSeconds(mc machine.CallContext) error
Constants ¶
This section is empty.
Variables ¶
var AddToRegistry = Builder.AddToRegistry
AddToRegistry registers all threading primitives.
var Builder = registry.NewRegistryBuilder(addThreads, addMutexes, addConditionVariables, addTime)
Builder aggregates all threading registration functions.
var Extension = registry.NewDescribedExtension("threads", "Concurrency: SRFI-18 threads, mutexes, condition variables, channels.", AddToRegistry)
Extension is the threads extension.
var PrimConditionVariableQ = helpers.MakeTypePredicate(func(o values.Value) bool { _, ok := o.(*values.ConditionVariable) return ok })
PrimConditionVariableQ tests if an object is a condition variable (condition-variable? obj) -> boolean
var PrimMutexQ = helpers.MakeTypePredicate(func(o values.Value) bool { _, ok := o.(*values.Mutex) return ok })
PrimMutexQ tests if an object is a mutex (mutex? obj) -> boolean
var PrimThreadQ = helpers.MakeTypePredicate(func(o values.Value) bool { _, ok := o.(*values.Thread) return ok })
PrimThreadQ tests if an object is a thread (thread? obj) -> boolean
var PrimTimeQ = helpers.MakeTypePredicate(func(o values.Value) bool { _, ok := o.(*values.Time) return ok })
PrimTimeQ tests if an object is a time (time? obj) -> boolean
Functions ¶
func PrimConditionVariableBroadcast ¶
func PrimConditionVariableBroadcast(mc machine.CallContext) error
PrimConditionVariableBroadcast signals all waiting threads (condition-variable-broadcast! cv) -> void
func PrimConditionVariableName ¶
func PrimConditionVariableName(mc machine.CallContext) error
PrimConditionVariableName returns the condition variable's name (condition-variable-name cv) -> string or symbol
func PrimConditionVariableSignal ¶
func PrimConditionVariableSignal(mc machine.CallContext) error
PrimConditionVariableSignal signals one waiting thread (condition-variable-signal! cv) -> void
func PrimConditionVariableSpecific ¶
func PrimConditionVariableSpecific(mc machine.CallContext) error
PrimConditionVariableSpecific returns the condition variable's specific field (condition-variable-specific cv) -> value
func PrimConditionVariableSpecificSet ¶
func PrimConditionVariableSpecificSet(mc machine.CallContext) error
PrimConditionVariableSpecificSet sets the condition variable's specific field (condition-variable-specific-set! cv obj) -> void
func PrimCurrentThread ¶
func PrimCurrentThread(mc machine.CallContext) error
PrimCurrentThread returns the current executing thread. Returns the thread object if running inside a thread, or the symbol 'primordial for the main goroutine. (current-thread) -> thread
func PrimCurrentTime ¶
func PrimCurrentTime(mc machine.CallContext) error
PrimCurrentTime returns the current time (current-time) -> time
func PrimMakeConditionVariable ¶
func PrimMakeConditionVariable(mc machine.CallContext) error
PrimMakeConditionVariable creates a new condition variable (make-condition-variable [name]) -> condition-variable
func PrimMakeMutex ¶
func PrimMakeMutex(mc machine.CallContext) error
PrimMakeMutex creates a new mutex (make-mutex [name]) -> mutex
func PrimMakeThread ¶
func PrimMakeThread(cc machine.CallContext) error
PrimMakeThread creates a new thread (make-thread thunk [name]) -> thread
func PrimMutexLock ¶
func PrimMutexLock(mc machine.CallContext) error
PrimMutexLock acquires the mutex (mutex-lock! mutex [timeout [thread]]) -> boolean Returns #t if acquired, #f if timeout
func PrimMutexName ¶
func PrimMutexName(mc machine.CallContext) error
PrimMutexName returns the mutex's name (mutex-name mutex) -> string or symbol
func PrimMutexSpecific ¶
func PrimMutexSpecific(mc machine.CallContext) error
PrimMutexSpecific returns the mutex's specific field (mutex-specific mutex) -> value
func PrimMutexSpecificSet ¶
func PrimMutexSpecificSet(mc machine.CallContext) error
PrimMutexSpecificSet sets the mutex's specific field (mutex-specific-set! mutex obj) -> void
func PrimMutexState ¶
func PrimMutexState(mc machine.CallContext) error
PrimMutexState returns the mutex's state (mutex-state mutex) -> symbol or thread Returns: 'not-owned, 'abandoned, or the owner thread
func PrimMutexUnlock ¶
func PrimMutexUnlock(mc machine.CallContext) error
PrimMutexUnlock releases the mutex (mutex-unlock! mutex [condition-variable [timeout]]) -> boolean
func PrimSecondsToTime ¶
func PrimSecondsToTime(mc machine.CallContext) error
PrimSecondsToTime converts seconds to a time (seconds->time x) -> time
func PrimThreadJoin ¶
func PrimThreadJoin(mc machine.CallContext) error
PrimThreadJoin waits for a thread to terminate (thread-join! thread [timeout [timeout-val]]) -> value
func PrimThreadName ¶
func PrimThreadName(mc machine.CallContext) error
PrimThreadName returns the thread's name (thread-name thread) -> string or symbol
func PrimThreadSleep ¶
func PrimThreadSleep(mc machine.CallContext) error
PrimThreadSleep pauses execution for a time (thread-sleep! timeout) -> void timeout can be a time object or a number (seconds)
func PrimThreadSpecific ¶
func PrimThreadSpecific(mc machine.CallContext) error
PrimThreadSpecific returns the thread's specific field (thread-specific thread) -> value
func PrimThreadSpecificSet ¶
func PrimThreadSpecificSet(mc machine.CallContext) error
PrimThreadSpecificSet sets the thread's specific field (thread-specific-set! thread obj) -> void
func PrimThreadStart ¶
func PrimThreadStart(mc machine.CallContext) error
PrimThreadStart starts a thread (thread-start! thread) -> thread
func PrimThreadTerminate ¶
func PrimThreadTerminate(mc machine.CallContext) error
PrimThreadTerminate forcefully terminates a thread (thread-terminate! thread) -> void
func PrimThreadYield ¶
func PrimThreadYield(mc machine.CallContext) error
PrimThreadYield yields execution to other threads (thread-yield!) -> void
func PrimTimeToSeconds ¶
func PrimTimeToSeconds(mc machine.CallContext) error
PrimTimeToSeconds converts a time to seconds (time->seconds time) -> number
Types ¶
This section is empty.