mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-11-04 06:18:14 +01:00
bounded_threadsafe_queue: Deduplicate and add PushModes
Adds the PushModes Try and Wait to allow producers to specify how they want to push their data to the queue if the queue is full. If the queue is full: - Try will fail to push to the queue, returning false. Try only returns true if it successfully pushes to the queue. This may result in items not being pushed into the queue. - Wait will wait until a slot is available to push to the queue, resulting in potential for deadlock if a consumer is not running.
This commit is contained in:
1 parent
281e99f09d
commit
62fd55e5fe
3 files changed
+95
-97
No files matched your search
@@ -118,7 +118,7 @@ u64 ThreadManager::PushCommand(CommandData&& command_data, bool block) {
|
||||
|
||||
std::unique_lock lk(state.write_lock);
|
||||
const u64 fence{++state.last_fence};
|
||||
state.queue.Push(std::move(command_data), fence, block);
|
||||
state.queue.EmplaceWait(std::move(command_data), fence, block);
|
||||
|
||||
if (block) {
|
||||
Common::CondvarWait(state.cv, lk, thread.get_stop_token(), [this, fence] {
|
||||
|
||||
Reference in new issue
Block a user