struct

Syn::Core::SpinLock

Inherits Struct / Value / Object

Tries to acquire an atomic lock by spining, trying to avoid slow thread context switches that involve the kernel scheduler but eventually fallback to yielding to another thread, to avoid spinning (and thus burning) a CPU that would be counter-productive (scheduler may believe the thread is doing some heavy computation and delay it's suspension).

This is a public alternative to the private Crystal::SpinLock in stdlib. That beind said, you're not supposed to ever need it.

The implementation is a NOOP until the program has enabling MT during compilation (i.e. -Dpreview_mt flag).

Constructors

Instance methods

initialize
Source
lock
Source
synchronize

Locks, yields and unlocks.

NOTE: make sure that the block doesn't execute anything more than necessary, since concurrent threads will be blocked for its whole duration!

Source
unlock
Source