StatusWith<TaskExecutor::CallbackHandle> ThreadPoolTaskExecutor::enqueueCallbackState_inlock( WorkQueue* queue, CallbackFn work, Date_t when) { auto event = makeEvent_inlock(); if (!event.isOK()) { return event.getStatus(); } queue->emplace_back(CallbackState::make(std::move(work), std::move(event.getValue()), when)); queue->back()->iter = std::prev(queue->end()); CallbackHandle cbHandle; setCallbackForHandle(&cbHandle, queue->back()); return cbHandle; }
StatusWith<ReplicationExecutor::CallbackHandle> ReplicationExecutor::enqueueWork_inlock( WorkQueue* queue, const CallbackFn& callback) { invariant(callback); StatusWith<EventHandle> event = makeEvent_inlock(); if (!event.isOK()) return StatusWith<CallbackHandle>(event.getStatus()); if (_freeQueue.empty()) _freeQueue.push_front(WorkItem()); const WorkQueue::iterator iter = _freeQueue.begin(); iter->generation++; iter->callback = callback; iter->finishedEvent = event.getValue(); iter->readyDate = Date_t(); iter->isCanceled = false; queue->splice(queue->end(), _freeQueue, iter); return StatusWith<CallbackHandle>(CallbackHandle(iter)); }
StatusWith<ReplicationExecutor::EventHandle> ReplicationExecutor::makeEvent() { boost::lock_guard<boost::mutex> lk(_mutex); return makeEvent_inlock(); }
StatusWith<TaskExecutor::EventHandle> ThreadPoolTaskExecutor::makeEvent() { stdx::lock_guard<stdx::mutex> lk(_mutex); return makeEvent_inlock(); }