Module iceoryx2_bb_threadsafe::trigger_queue
source · Expand description
A threadsafe queue which triggers a consumer when data arrived or triggers the producer when the queue is no longer full.
§Example
use std::thread;
use iceoryx2_bb_threadsafe::trigger_queue::*;
const CAPACITY: usize = 16;
let mtx_handle = MutexHandle::new();
let free_handle = UnnamedSemaphoreHandle::new();
let used_handle = UnnamedSemaphoreHandle::new();
let queue = TriggerQueue::<u64, CAPACITY>::new(&mtx_handle, &free_handle, &used_handle);
thread::scope(|s| {
let consumer = s.spawn(|| {
for i in 0..10 {
println!("got: {}", queue.blocking_pop());
}
});
let producer = s.spawn(|| {
for i in 0..10 {
queue.blocking_push(i);
println!("pushed data {}", i);
}
});
})Structs§
- Represents a POSIX mutex which can be created by the
MutexBuilder. - Creates a
Mutex. - A guard which allows the modification of a value guarded by a
Mutex. It is returned inMutex::lock(),Mutex::try_lock()andMutex::timed_lock(). - Represents a POSIX named semaphore - a semaphore with a corresponding file handle which can be opened by other processes. The filename corresponds to the semaphore name. A named semaphore is created by the
NamedSemaphoreBuilder. - Builder for the
NamedSemaphore. - Provides additional settings which are only available for newly created semaphores. Is returned by
NamedSemaphoreBuilder::creation_mode(). - Defines the permission of a file or directory in a POSIX system.
- An unnamed semaphore which can be used process locally or for inter-process triggers.
- Creates an
UnnamedSemaphorewhich can be either used process locally or can be stored in a shared memory segment and then used during inter-process communication.
Enums§
- Represents different low level clocks.
- Describes how new resources like
crate::file::File,crate::shared_memory::SharedMemoryor others should be created. - The MutexError enum is a generalization when one doesn’t require the fine-grained error handling enums. One can forward MutexError as more generic return value when a method returns a Mutex***Error. On a higher level it is again convertable to
crate::Error. - Defines how the priority of a mutex owning thread changes when another thread with an higher priority would like to acquire the mutex.
- Defines the behavior when a mutex owning thread is terminated
- The type of a mutex defines its behavior.
- The SemaphoreError enum is a generalization when one doesn’t require the fine-grained error handling enums. One can forward SemaphoreError as more generic return value when a method returns a Semaphore***Error. On a higher level it is again convertable to
crate::Error.
Traits§
- Represents a handle that is in general inter-process capable.
- Represents struct that can be configured for inter-process use.
- Defines the interface of a
NamedSemaphoreand anUnnamedSemaphore.