Thread
Ioto is single threaded and uses fiber coroutines for parallelism. Ioto is not thread safe and you cannot call Ioto APIs from program threads without ensuring all access to Ioto data structures are serialized via thread locks.
Ioto provides a cross platform thread library so you can create threads and implement appropriate locks.
NOTE: this is not a recommended design pattern. It is simpler, faster and more reliable to use fiber coroutines that to use threaded programming.
API Tour
Locking
To create a lock:
1 |
|
and to free a lock
1 |
|
To assert a lock, use rLock. This will block the current thread until resumed.
NOTE: do not use this call in a fiber.
1 |
|
To unlock:
1 |
|
To try for a lock without waiting or blocking:
1 2 3 |
|
Spin Locks
Ioto also provides spin locks which may be faster on some operating systems:
API Reference
The full API is specified here: