Add spinlock implementation without std::thread::sleep
#138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds aspin-plain
feature that uses a spinlock-based locking system like thespin
feature does, but without usingstd::thread::sleep
. Closes #137.Edit: This pull request changes the
spin
feature to only usestd::thread::sleep
on Unix and Windows. Closes #137.Some targets like
wasm32-unknown-unknown
don't support blocking, so you won't be able to use flume on those platforms without this new feature. Even if you enable-Ctarget-feature=+atomics,+bulk-memory,+mutable-globals
on thewasm32-unknown-unknown
target, flume still doesn't work on the main thread of a web browser, it only works in web workers. See #137 for more details about this, but essentially the problem is that thewait_lock
function in flume has two different implementations and both of them are blocking, including the current spinlock-based one.