syncvar: a library of synchronous variables
The syncvar library is a library to access synchronous variables inspired by CML.
1 Reference
(require syncvar) | package: syncvar-lib |
This library primarily provides Id style synchronous variables. These variables have two states: empty and full. When a thread attempts to read a variable that is empty the thread will block until it is full. Any attempt to write a value to a full variable will raise an exception.
1.1 IVars
(require syncvar/ivar) | package: syncvar-lib |
An ivar is a write once synchronous variable. Once an ivar is in the full state it cannot go back to the empty state.
In addition to its use with ivar-specific procedures, an ivar can be used as a synchronizable event. An ivar is ready for synchronization when ivar-get would not block; the synchronization result is the same as the ivar-get result.
procedure
(ivar-try-get an-ivar) → any
an-ivar : ivar?
procedure
(ivar-get-evt an-ivar) → evt?
an-ivar : ivar?
procedure
(exn:fail:ivar? v) → boolean?
v : any/c
1.2 MVars
(require syncvar/mvar) | package: syncvar-lib |
A mvar is a mutable synchronous variable.
procedure
(mvar-take! a-mvar) → any
a-mvar : mvar?
procedure
(mvar-try-take! a-mvar) → any
a-mvar : mvar?
procedure
(mvar-try-get a-mvar) → any
a-mvar : mvar?
procedure
(mvar-swap! a-mvar v) → any
a-mvar : mvar? v : any/c
If an error occurs while running f, then the original value will be stored in a-mvar.
Changed in version 0.9.3 of package syncvar-lib: fixed update error behavior
procedure
(mvar-take!-evt a-mvar) → evt?
a-mvar : mvar?
When this event is ready the stored value will be removed.
procedure
(mvar-get-evt a-mvar) → evt?
a-mvar : mvar?
procedure
(mvar-swap!-evt a-mvar v) → evt?
a-mvar : mvar? v : any/c
When this event is ready the value stored in a-mvar will be replaced with the value v.
When this event is ready the value stored in a-mvar will be replaced with a the value returned from applying f to the old value.
If an error occurs while running f, then the original value will be stored in a-mvar.
Changed in version 0.9.3 of package syncvar-lib: fixed update error behavior
procedure
(exn:fail:mvar? v) → boolean?
v : any/c
2 Changelog
2.1 0.9.3
Fix behavior in mvar-update!-evt when running the update function resulted in an error.
2.2 0.9.2
Fixed bug in mvar-update!-evt where the previous value was not returned.
2.3 0.9.1
Bumping version number to be valid.
2.4 0.9.0
Initial package server release.