Commit Graph

18 Commits

Author SHA1 Message Date
Robin Kertels
9d422d14d5
WorkQueueThread: Fix WaitForCompletion 2023-03-20 16:31:40 +01:00
Scott Mansell
2ff155f742 Optimise cond_var predicate order
m_items.empty() is by far the most likely reason for a notification.
2023-02-05 17:20:00 +13:00
Scott Mansell
271ffde71d Prevent WaitForCompletion shutdown deadlock.
Adjust shutdown order to prevent potential deadlocks
when one thread calls Shutdown, and another calls WaitForCompletion.
2023-02-05 17:17:16 +13:00
Scott Mansell
9c012b09b3 Address review feedback 2023-02-05 16:52:53 +13:00
Scott Mansell
7c4fcc30a3 WorkQueueThread: provide name and function at same time 2023-02-04 15:56:27 +13:00
Scott Mansell
6594532f10 WorkQueueThread: rework Cancel/Shutdown workflow
- Cancel doesn't shut down anymore.
   Allowing it to be used multiple times thoughout the life of
   the WorkQueue
 - Remove Clear, so we only have Cancel semantics
 - Add IsCancelling so work items can abort early if cancelling
 - Replace m_cancelled and m_thread.joinable() guars with m_shutdown.
 - Rename Flush to WaitForCompletion (As it's ambiguous if a function
   called flush should be blocking or not)
 - Add documentation
2023-02-04 14:58:12 +13:00
Scott Mansell
acdb0c5be1 WorkQueueThread: Implement thread name
Otherwise we will end up with a dozen threads named "WorkQueueThread"
2023-02-04 14:58:12 +13:00
Robin Kertels
94a0c50bf8 WorkQueueThread: Rework without Flags/Events 2023-02-04 14:31:16 +13:00
Robin Kertels
9affbfe683 WorkQueueThread: Implement proper Flush
and rename the existing Flush to FlushOne.
2023-02-04 14:31:16 +13:00
Robin Kertels
9badcc6eb8 WorkQueueThread: Add Push 2023-02-04 14:31:16 +13:00
Scott Mansell
512273a507 WorkQueueThread: Add flush capability 2023-02-04 14:31:16 +13:00
Admiral H. Curtiss
79efd5df1e
Common/WorkQueueThread: Make Shutdown() public, so users can wait for all currently queued tasks to finish when shutting down the thread. 2022-10-01 23:58:52 +02:00
Pierre Bourdon
e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00
Christian Aguilera
213610e95d Extended WorkQueueThread class with Clear(), Cancel() and IsCancelled(). 2020-10-01 22:09:45 +02:00
Shawn Hoffman
6ef9d70701 name some threads 2020-08-22 17:22:07 -07:00
Silent
26ebf5b650
Improvements to WorkQueueThread
- Do not use a lambda for std::thread as invoke constructor exists
- Use simpler std::lock_guard wherever possible
- Do not require T to be default constructible
- Move T out of the queue instead of copying
2019-10-08 22:57:33 +02:00
Michael M
8c13e0230c GameTracker: use WorkQueueThread 2017-08-20 14:40:56 -07:00
Michael M
de9378bf63 Common: add WorkQueueThread 2017-08-20 14:40:56 -07:00