5.14 Operating System Threads
(require ffi/unsafe/os-thread) | package: base |
Added in version 6.90.0.9 of package base.
procedure
procedure
(call-in-os-thread thunk) → void?
thunk : (-> any)
The thunk is run in atomic mode, and it must not inspect its continuation or use any Racket thread functions (such as thread or current-thread), any Racket synchronization functions (such as semaphore-post or sync), or any parameters (such as current-output-port). Variables may be safely mutated with set!, and vectors, mutable pairs, boxes, mutable structure fields, and eq?- and eqv?-based hash tables can be mutated, but the visibility of mutations to other threads is unspecified except as synchronized through os-semaphore-wait and os-semaphore-post.
procedure
(make-os-semaphore) → any
procedure
(os-semaphore-post sema) → void?
sema : any/c
procedure
(os-semaphore-wait sema) → void?
sema : any/c
5.14.1 Operating System Asynchronous Channels
(require ffi/unsafe/os-async-channel) | package: base |
An asynchronous operating-system channel is a synchronizable event, so can it can be used with sync to receive a value in a Racket thread. Other threads must use os-async-channel-try-get or os-async-channel-get.
When a thread is blocked on an otherwise inaccessible asynchronous channel that was produced by make-os-async-channel, the thread is not available for garbage collection. That’s different from a thread is blocked on a regular Racket channel or a place channel.
Added in version 8.0.0.4 of package base.
procedure
procedure
(os-async-channel? v) → boolean?
v : any/c
procedure
(os-async-channel-put ch v) → void?
ch : os-async-channel? v : any/c
procedure
(os-async-channel-try-get ch [default-v]) → any/c
ch : os-async-channel? default-v : any/c = #f
procedure
(os-async-channel-get ch) → any/c
ch : os-async-channel?