コード例 #1
0
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;
}
コード例 #2
0
    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));
    }
コード例 #3
0
 StatusWith<ReplicationExecutor::EventHandle> ReplicationExecutor::makeEvent() {
     boost::lock_guard<boost::mutex> lk(_mutex);
     return makeEvent_inlock();
 }
コード例 #4
0
StatusWith<TaskExecutor::EventHandle> ThreadPoolTaskExecutor::makeEvent() {
    stdx::lock_guard<stdx::mutex> lk(_mutex);
    return makeEvent_inlock();
}