@@ -25,11 +25,11 @@ namespace Bloomberg {
2525namespace quantum {
2626
2727inline
28- TaskQueue::WorkItem::WorkItem (TaskPtr task,
28+ TaskQueue::WorkItem::WorkItem (ITaskPtr task,
2929 TaskListIter iter,
3030 bool isBlocked,
3131 unsigned int blockedQueueRound) :
32- _task (task),
32+ _task (std::move( task) ),
3333 _iter (iter),
3434 _isBlocked (isBlocked),
3535 _blockedQueueRound (blockedQueueRound)
@@ -52,9 +52,8 @@ TaskQueue::TaskQueue() :
5252
5353inline
5454TaskQueue::TaskQueue (const Configuration&, std::shared_ptr<TaskQueue> sharedQueue) :
55- _alloc (Allocator<QueueListAllocator>::instance(AllocatorTraits::queueListAllocSize())),
56- _runQueue (_alloc),
57- _waitQueue (_alloc),
55+ _runQueue (Allocator<QueueListAllocator>::instance(AllocatorTraits::queueListAllocSize())),
56+ _waitQueue (Allocator<QueueListAllocator>::instance(AllocatorTraits::queueListAllocSize())),
5857 _queueIt (_runQueue.end()),
5958 _blockedIt (_runQueue.end()),
6059 _isBlocked (false ),
@@ -64,7 +63,7 @@ TaskQueue::TaskQueue(const Configuration&, std::shared_ptr<TaskQueue> sharedQueu
6463 _isIdle (true ),
6564 _terminated (false ),
6665 _isAdvanced (false ),
67- _sharedQueue (sharedQueue),
66+ _sharedQueue (std::move( sharedQueue) ),
6867 _queueRound (0 ),
6968 _lastSleptQueueRound (std::numeric_limits<unsigned int >::max()),
7069 _lastSleptSharedQueueRound (std::numeric_limits<unsigned int >::max())
@@ -80,7 +79,29 @@ inline
8079TaskQueue::TaskQueue (const TaskQueue&) :
8180 TaskQueue ()
8281{
82+ }
8383
84+ inline
85+ TaskQueue::TaskQueue (TaskQueue&& other) noexcept :
86+ _thread (std::move(other._thread)),
87+ _runQueue (std::move(other._runQueue)),
88+ _waitQueue (std::move(other._waitQueue)),
89+ _queueIt (other._queueIt),
90+ _blockedIt (_runQueue.end()),
91+ _isBlocked (other._isBlocked),
92+ _isEmpty (other._isEmpty.load()),
93+ _isSharedQueueEmpty (other._isSharedQueueEmpty.load()),
94+ _isInterrupted (other._isInterrupted.load()),
95+ _isIdle (other._isIdle.load()),
96+ _terminated (other._terminated.load()),
97+ _isAdvanced (other._isAdvanced),
98+ _stats (other._stats),
99+ _sharedQueue (std::move(other._sharedQueue)),
100+ _helpers (other._helpers),
101+ _queueRound (other._queueRound),
102+ _lastSleptQueueRound (other._lastSleptQueueRound),
103+ _lastSleptSharedQueueRound (other._lastSleptSharedQueueRound)
104+ {
84105}
85106
86107inline
@@ -183,10 +204,10 @@ TaskQueue::ProcessTaskResult TaskQueue::processTask()
183204 // Process a task
184205 workItem = grabWorkItem ();
185206
186- TaskPtr task = workItem._task ;
207+ ITaskPtr task = workItem._task ;
187208 if (!task)
188209 {
189- return ProcessTaskResult ( workItem._isBlocked , workItem._blockedQueueRound ) ;
210+ return { workItem._isBlocked , workItem._blockedQueueRound } ;
190211 }
191212
192213 int rc;
@@ -231,7 +252,7 @@ TaskQueue::ProcessTaskResult TaskQueue::processTask()
231252 {
232253 handleException (workItem);
233254 }
234- return ProcessTaskResult ( workItem._isBlocked , workItem._blockedQueueRound ) ;
255+ return { workItem._isBlocked , workItem._blockedQueueRound } ;
235256}
236257
237258inline
@@ -453,7 +474,7 @@ bool TaskQueue::handleSuccess(const WorkItem& workItem)
453474{
454475 ITaskContinuation::Ptr nextTask;
455476 // check if there's another task scheduled to run after this one
456- nextTask = workItem._task ->getNextTask ();
477+ nextTask = std::static_pointer_cast<Task>( workItem._task ) ->getNextTask ();
457478 if (nextTask && (nextTask->getType () == ITask::Type::ErrorHandler))
458479 {
459480 // skip error handler since we don't have any errors
@@ -473,7 +494,7 @@ bool TaskQueue::handleError(const WorkItem& workItem)
473494{
474495 ITaskContinuation::Ptr nextTask;
475496 // Check if we have a final task to run
476- nextTask = workItem._task ->getErrorHandlerOrFinalTask ();
497+ nextTask = std::static_pointer_cast<Task>( workItem._task ) ->getErrorHandlerOrFinalTask ();
477498 // queue next task and de-queue current one
478499 enqueue (nextTask);
479500 doDequeue (_isIdle, workItem._iter );
@@ -537,9 +558,9 @@ TaskQueue::grabWorkItem()
537558 _isIdle = _runQueue.empty ();
538559 if (_runQueue.empty ())
539560 {
540- return WorkItem ( nullptr , _runQueue.end (), _isBlocked, _queueRound) ;
561+ return { nullptr , _runQueue.end (), _isBlocked, _queueRound} ;
541562 }
542- return WorkItem (( *_queueIt), _queueIt, false , 0 ) ;
563+ return {( *_queueIt), _queueIt, false , 0 } ;
543564}
544565
545566inline
0 commit comments