// // Copyright 2016 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // WorkerThread: // Task running thread for ANGLE, similar to a TaskRunner in Chromium. // Might be implemented differently depending on platform. //
#include"libANGLE/WorkerThread.h"
#include"libANGLE/trace.h"
#if (ANGLE_DELEGATE_WORKERS == ANGLE_ENABLED) || (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED) # include <condition_variable> # include <future> # include <mutex> # include <queue> # include <thread> #endif// (ANGLE_DELEGATE_WORKERS == ANGLE_ENABLED) || (ANGLE_STD_ASYNC_WORKERS == ANGLE_ENABLED)
class SingleThreadedWaitableEvent final : public WaitableEvent
{ public:
SingleThreadedWaitableEvent() = default;
~SingleThreadedWaitableEvent() override = default;
// To block wait() when the task is still in queue to be run. // Also to protect the concurrent accesses from both main thread and // background threads to the member fields.
std::mutex mMutex;
// A function wrapper to execute the closure and to notify the waitable // event after the execution. class DelegateWorkerTask
{ public:
DelegateWorkerTask(std::shared_ptr<Closure> task,
std::shared_ptr<DelegateWaitableEvent> waitable)
: mTask(task), mWaitable(waitable)
{}
DelegateWorkerTask() = delete;
DelegateWorkerTask(DelegateWorkerTask &) = delete;
std::shared_ptr<WaitableEvent> DelegateWorkerPool::postWorkerTask(std::shared_ptr<Closure> task)
{ auto waitable = std::make_shared<DelegateWaitableEvent>();
// The task will be deleted by DelegateWorkerTask::RunTask(...) after its execution.
DelegateWorkerTask *workerTask = new DelegateWorkerTask(task, waitable); auto *platform = ANGLEPlatformCurrent();
platform->postWorkerTask(platform, DelegateWorkerTask::RunTask, workerTask);
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.