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.
To create a lock:
and to free a lock
To assert a lock, use rLock. This will block the current thread until resumed.
NOTE: do not use this call in a fiber.
To try for a lock without waiting or blocking:
1 2 3
Ioto also provides spin locks which may be faster on some operating systems:
The full API is specified here: