frost.threads

Class Lock

    └ Immutable
         └ Object

A lock (mutex) which allows multiple threads to coordinate access to a shared resource. Locks are typically unnecessary in Frost, as only immutable data can be shared between threads without resorting to unsafe code.

Source Code:
View Source

Initializer Summary

init()
Creates a new, unlocked Lock.
Inherited Fields:

Instance Method Summary

lock()
Blocks the current thread until the lock is available, and then locks it.
unlock()
Releases a held lock.

Initializers

init ()

Creates a new, unlocked Lock.

Instance Methods

method lock ()

Blocks the current thread until the lock is available, and then locks it. While the lock is held, any other threads which attempt to lock the Lock will block until the current thread releases the Lock.

It is legal for a thread to lock the same Lock multiple times; the same number of unlock() calls will be necessary to completely release the Lock.

See also:
unlock()
method unlock ()

Releases a held lock. Unlocking a Lock which has not actually been locked by the current thread is undefined behavior.

See also:
lock()