alias Mutex

Overview

A fiber-safe mutex.

Provides deadlock protection by default. Attempting to re-lock the mutex from the same fiberwill raise an exception. Trying to unlock an unlocked mutex, or a mutex locked by another fiberwill raise an exception.

The reentrant protection maintains a lock count. Attempting to re-lock the mutex from the same fiberwill increment the lock count. Attempting to unlock the counter from the same fiberwill decrement the lock count, eventually releasing the lockwhen the lock count returns to 0. Attempting to unlock an unlocked mutex, or a mutex locked by another fiberwill raise an exception.

You also disable all protectionswithunchecked. Attempting to re-lock the mutex from the same fiberwill deadlock. Any fiber can unlock the mutex, even if itwasn't previously locked.

WARNING Mutex is deprecated as of Crystal 1.20. UseSync::Mutex instead.

Alias Definition

Sync::Mutex

Defined in:

mutex.cr