mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-27 06:35:04 +00:00
Installs additional safeguards against unsafe deconstruction.
This commit is contained in:
parent
87760297fc
commit
83f73c3f02
@ -80,6 +80,10 @@ void AsyncTaskQueue::flush() {
|
||||
#endif
|
||||
}
|
||||
|
||||
DeferringAsyncTaskQueue::~DeferringAsyncTaskQueue() {
|
||||
perform();
|
||||
}
|
||||
|
||||
void DeferringAsyncTaskQueue::defer(std::function<void(void)> function) {
|
||||
if(!deferred_tasks_) {
|
||||
deferred_tasks_.reset(new std::list<std::function<void(void)>>);
|
||||
|
@ -30,7 +30,7 @@ namespace Concurrency {
|
||||
class AsyncTaskQueue {
|
||||
public:
|
||||
AsyncTaskQueue();
|
||||
~AsyncTaskQueue();
|
||||
virtual ~AsyncTaskQueue();
|
||||
|
||||
/*!
|
||||
Adds @c function to the queue.
|
||||
@ -69,6 +69,8 @@ class AsyncTaskQueue {
|
||||
*/
|
||||
class DeferringAsyncTaskQueue: public AsyncTaskQueue {
|
||||
public:
|
||||
~DeferringAsyncTaskQueue();
|
||||
|
||||
/*!
|
||||
Adds a function to the deferral list.
|
||||
|
||||
|
@ -17,6 +17,11 @@ BestEffortUpdater::BestEffortUpdater() {
|
||||
update_is_ongoing_.clear();
|
||||
}
|
||||
|
||||
BestEffortUpdater::~BestEffortUpdater() {
|
||||
// Don't allow further deconstruction until the task queue is stopped.
|
||||
flush();
|
||||
}
|
||||
|
||||
void BestEffortUpdater::update() {
|
||||
// Perform an update only if one is not currently ongoing.
|
||||
if(!update_is_ongoing_.test_and_set()) {
|
||||
|
@ -26,6 +26,7 @@ namespace Concurrency {
|
||||
class BestEffortUpdater {
|
||||
public:
|
||||
BestEffortUpdater();
|
||||
~BestEffortUpdater();
|
||||
|
||||
/// A delegate receives timing cues.
|
||||
struct Delegate {
|
||||
|
@ -106,6 +106,7 @@ class MachineDocument:
|
||||
|
||||
bestEffortLock.lock()
|
||||
bestEffortUpdater!.delegate = nil
|
||||
bestEffortUpdater!.flush()
|
||||
bestEffortUpdater = nil
|
||||
bestEffortLock.unlock()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user