@@ -12,9 +12,9 @@ DispatchQueue::DispatchQueue(size_t dispatchCap):
12
12
13
13
DispatchQueue::DispatchQueue (DispatchQueue&& q):
14
14
m_dispatchCap(q.m_dispatchCap),
15
- m_aborted(q.m_aborted )
15
+ onAborted(std::move(q.onAborted) )
16
16
{
17
- if (!m_aborted )
17
+ if (!onAborted )
18
18
*this += std::move (q);
19
19
}
20
20
@@ -72,7 +72,7 @@ void DispatchQueue::Abort(void) {
72
72
DispatchThunkBase* pHead;
73
73
{
74
74
std::lock_guard<std::mutex> lk (m_dispatchLock);
75
- m_aborted = true ;
75
+ onAborted () ;
76
76
m_dispatchCap = 0 ;
77
77
pHead = m_pHead;
78
78
m_pHead = nullptr ;
@@ -104,15 +104,15 @@ void DispatchQueue::WakeAllWaitingThreads(void) {
104
104
105
105
void DispatchQueue::WaitForEvent (void ) {
106
106
std::unique_lock<std::mutex> lk (m_dispatchLock);
107
- if (m_aborted )
107
+ if (onAborted )
108
108
throw dispatch_aborted_exception (" Dispatch queue was aborted prior to waiting for an event" );
109
109
110
110
// Unconditional delay:
111
111
uint64_t version = m_version;
112
112
m_queueUpdated.wait (
113
113
lk,
114
114
[this , version] {
115
- if (m_aborted )
115
+ if (onAborted )
116
116
throw dispatch_aborted_exception (" Dispatch queue was aborted while waiting for an event" );
117
117
118
118
return
@@ -153,7 +153,7 @@ bool DispatchQueue::WaitForEvent(std::chrono::steady_clock::time_point wakeTime)
153
153
}
154
154
155
155
bool DispatchQueue::WaitForEventUnsafe (std::unique_lock<std::mutex>& lk, std::chrono::steady_clock::time_point wakeTime) {
156
- if (m_aborted )
156
+ if (onAborted )
157
157
throw dispatch_aborted_exception (" Dispatch queue was aborted prior to waiting for an event" );
158
158
159
159
while (!m_pHead) {
@@ -165,7 +165,7 @@ bool DispatchQueue::WaitForEventUnsafe(std::unique_lock<std::mutex>& lk, std::ch
165
165
std::cv_status status = m_queueUpdated.wait_until (lk, wakeTime);
166
166
167
167
// Short-circuit if the queue was aborted
168
- if (m_aborted )
168
+ if (onAborted )
169
169
throw dispatch_aborted_exception (" Dispatch queue was aborted while waiting for an event" );
170
170
171
171
if (PromoteReadyDispatchersUnsafe ())
@@ -223,7 +223,7 @@ bool DispatchQueue::Barrier(std::chrono::nanoseconds timeout) {
223
223
std::unique_lock<std::mutex> lk (m_dispatchLock);
224
224
225
225
// Short-circuit if dispatching has been aborted
226
- if (m_aborted )
226
+ if (onAborted )
227
227
throw dispatch_aborted_exception (" Dispatch queue was aborted before a timed wait was attempted" );
228
228
229
229
// Short-circuit if the queue is already empty
@@ -246,8 +246,8 @@ bool DispatchQueue::Barrier(std::chrono::nanoseconds timeout) {
246
246
lk.lock ();
247
247
248
248
// Wait until our variable is satisfied, which might be right away:
249
- bool rv = m_queueUpdated.wait_for (lk, timeout, [&] { return m_aborted || *complete; });
250
- if (m_aborted )
249
+ bool rv = m_queueUpdated.wait_for (lk, timeout, [&] { return onAborted || *complete; });
250
+ if (onAborted )
251
251
throw dispatch_aborted_exception (" Dispatch queue was aborted during a timed wait" );
252
252
return rv;
253
253
}
@@ -259,8 +259,8 @@ void DispatchQueue::Barrier(void) {
259
259
260
260
// Obtain the lock, wait until our variable is satisfied, which might be right away:
261
261
std::unique_lock<std::mutex> lk (m_dispatchLock);
262
- m_queueUpdated.wait (lk, [&] { return m_aborted || complete; });
263
- if (m_aborted )
262
+ m_queueUpdated.wait (lk, [&] { return onAborted || complete; });
263
+ if (onAborted )
264
264
// At this point, the dispatch queue MUST be completely run down. We have no outstanding references
265
265
// to our stack-allocated "complete" variable. Furthermore, after m_aborted is true, no further
266
266
// dispatchers are permitted to be run.
0 commit comments