Module glommio::sync[][src]

Set of synchronization primitives.

This create provides set of synchronization primitives which are optimized to be used inside of fibers which are driven by single-thread bounded executor.

Following primitives are provided.

  1. Semaphore - A counting semaphore. Semaphore maintains a set of permits. Each call to [‘acquire_permit’] suspends fiber if necessary until a permit is available, and then takes it. Each call to [‘signal’] adds a permit, potentially releasing a suspended acquirer. There is also [‘try_acquire’] method which fails if semaphore lacks of permits requested without suspending the fiber.

  2. RwLock - Implementation of read-write lock optimized for single-thread bounded executor. All methods of RwLock have the same meaning as the methods of std::sync::RwLock. With exception that RwLock can not be poisoned but can be closed.

Structs

Gate

Facility to achieve graceful shutdown by waiting for the dependent tasks to complete.

Pass

A visitor pass which could be acquired when entering a gate, and should be released before the gate is closed.

Permit

The permit is A RAII-friendly way to acquire semaphore resources.

RwLock

A reader-writer lock

RwLockReadGuard

RAII structure used to release the shared read access of a lock when dropped.

RwLockWriteGuard

RAII structure used to release the exclusive write access of a lock when dropped.

Semaphore

An implementation of semaphore that doesn’t use helper threads, condition variables, and is friendly to single-threaded execution.

StaticPermit

The static permit is A RAII-friendly way to acquire semaphore resources in long-lived operations that require a static lifetime.

Type Definitions

LockResult

A type alias for the result of a lock method which can be suspended.

TryLockResult

A type alias for the result of a non-suspending locking method.