本文整理汇总了C++中Task::complete方法的典型用法代码示例。如果您正苦于以下问题:C++ Task::complete方法的具体用法?C++ Task::complete怎么用?C++ Task::complete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::complete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closeFileCallback
static void closeFileCallback(uv_fs_t* handle)
{
Task* task = static_cast<Task*>(handle->data);
// Close returns nothing.
task->complete(NULL);
}
示例2: run
void TaskSchedulerSys::run(size_t threadIndex, size_t threadCount)
{
while (true)
{
/* wait for available task */
mutex.lock();
while ((end-begin) == 0 && !terminateThreads) {
condition.wait(mutex); continue;
}
/* terminate this thread */
if (terminateThreads) {
mutex.unlock(); return;
}
/* take next task from stack */
size_t i = (end-1)&(tasks.size()-1);
Task* task = tasks[i];
size_t elt = --task->started;
if (elt == 0) end--;
mutex.unlock();
/* run the task */
TaskScheduler::Event* event = task->event;
thread2event[threadIndex] = event;
if (task->run) task->run(task->runData,threadIndex,threadCount,elt,task->elts,task->event);
/* complete the task */
if (--task->completed == 0) {
if (task->complete) task->complete(task->completeData,threadIndex,threadCount,task->event);
if (event) event->dec();
}
}
}
示例3: openFileCallback
static void openFileCallback(uv_fs_t* handle)
{
// TODO(bob): Handle errors!
Task* task = static_cast<Task*>(handle->data);
// Note that the file descriptor is returned in [result] and not [file].
task->complete(new FileObject(handle->result));
}
示例4: getSizeCallback
static void getSizeCallback(uv_fs_t* handle)
{
// TODO(bob): Handle errors!
Task* task = static_cast<Task*>(handle->data);
// TODO(bob): Use handle.statbuf after upgrading to latest libuv where
// that's public.
uv_statbuf_t* statbuf = static_cast<uv_statbuf_t*>(handle->ptr);
task->complete(new IntObject(statbuf->st_size));
}
示例5: work
void TaskSchedulerSys::work(size_t threadIndex, size_t threadCount, bool wait)
{
/* wait for available task */
mutex.lock();
while ((end-begin) == 0 && !terminateThreads) {
if (wait) condition.wait(mutex);
else { mutex.unlock(); return; }
}
/* terminate this thread */
if (terminateThreads) {
mutex.unlock();
throw TaskScheduler::Terminate();
}
/* take next task from stack */
size_t i = (end-1)&(tasks.size()-1);
Task* task = tasks[i];
size_t elt = --task->started;
if (elt == 0) end--;
mutex.unlock();
/* run the task */
TaskScheduler::Event* event = task->event;
thread2event[threadIndex].event = event;
if (task->run) {
size_t taskID = TaskLogger::beginTask(threadIndex,task->name,elt);
task->run(task->runData,threadIndex,threadCount,elt,task->elts,task->event);
TaskLogger::endTask(threadIndex,taskID);
}
/* complete the task */
if (--task->completed == 0) {
if (task->complete) {
size_t taskID = TaskLogger::beginTask(threadIndex,task->name,0);
task->complete(task->completeData,threadIndex,threadCount,task->event);
TaskLogger::endTask(threadIndex,taskID);
}
if (event) event->dec();
}
}