class ScopedTaskRunner
Defined at line 89 of file ../../src/lib/callback/scoped_task_runner.h
An object that wraps the posting logic of an |async_t|, but that is
not copyable and will generally not run any task after being deleted, though
edge case handling may differ between |Controller| implementations.
This class is mostly thread-safe, though it must not go out of scope while
any of its methods are being called, and handling of edge cases varies
depending on the controller implementation. Notably, the default |Controller|
is not synchronized, so |ShutDown| should occur on the dispatch thread (after
which destruction may happen on any thread).
Typically, this class should appear towards the end of the fields of an
owning class so that it goes out of scope before any state that tasks may
depend on.
This class may be used without a dispatcher, but the common use case is to
manage FIDL calls.
Public Methods
void ScopedTaskRunner (async_dispatcher_t * dispatcher)
Defined at line 23 of file ../../src/lib/callback/scoped_task_runner.cc
void ScopedTaskRunner (ScopedTaskRunner && )
Defined at line 26 of file ../../src/lib/callback/scoped_task_runner.cc
void ~ScopedTaskRunner ()
Defined at line 28 of file ../../src/lib/callback/scoped_task_runner.cc
ScopedTaskRunner & operator= (ScopedTaskRunner && )
Defined at line 30 of file ../../src/lib/callback/scoped_task_runner.cc
void ShutDown ()
Pre-emptively ends this ScopedTaskRunner's lifecycle. All subsequent tasks
will no-op. This method may block, depending on the |TaskController|
implementation. The default implementation does not block, so care should
be taken by callers that any tasks executing during shutdown do not depend
on state guarded by this instance, typically by calling this method from
the dispatch thread.
This method is idempotent and will automatically be called when this class
goes out of scope.
Defined at line 32 of file ../../src/lib/callback/scoped_task_runner.cc
void Reset ()
Shuts down the current controller and assigns a new |SimpleTaskController|.
Defined at line 34 of file ../../src/lib/callback/scoped_task_runner.cc
void PostTask (fit::closure task)
Posts a task to run as soon as possible on the dispatcher after the current
dispatch cycle.
Defined at line 36 of file ../../src/lib/callback/scoped_task_runner.cc
void PostTaskForTime (fit::closure task, zx::time target_time)
Posts a task to run as soon as possible after the specified |target_time|.
Defined at line 40 of file ../../src/lib/callback/scoped_task_runner.cc
void PostDelayedTask (fit::closure task, zx::duration delay)
Posts a task to run as soon as possible after the specified |delay|.
Defined at line 44 of file ../../src/lib/callback/scoped_task_runner.cc
void PostPeriodicTask (fit::closure task, zx::duration interval, bool invoke_now)
Convenience function to post a repeating periodic task. If |invoke_now| is
true, the task is run as soon as possible on the dispatcher after the
current dispatch cycle as well as periodically. Otherwise, the first
invocation of the task will be as soon as possible after the specified
|interval|.
Defined at line 48 of file ../../src/lib/callback/scoped_task_runner.cc
template <class Controller>
void ScopedTaskRunner (typename TaskController::Tag<Controller> controller_type, async_dispatcher_t * dispatcher)
Defined at line 94 of file ../../src/lib/callback/scoped_task_runner.h
void ScopedTaskRunner (const ScopedTaskRunner & )
Defined at line 98 of file ../../src/lib/callback/scoped_task_runner.h
ScopedTaskRunner & operator= (const ScopedTaskRunner & )
Defined at line 103 of file ../../src/lib/callback/scoped_task_runner.h
async_dispatcher_t * dispatcher ()
Defined at line 106 of file ../../src/lib/callback/scoped_task_runner.h
template <class Controller>
void Reset (typename TaskController::Tag<Controller> controller_type)
Shuts down the current controller and assigns a new one of the specified type.
Defined at line 124 of file ../../src/lib/callback/scoped_task_runner.h
template <class Task, class... Args>
auto MakeScoped (Task task, fit::parameter_pack<Args...> )
Scopes a task to the current task runner without scheduling it. This means
that the given function will be called when the returned function is called
if and only if this task runner has not been deleted or shut down.
Synchronization of the guard depends on the |TaskController|
implementation; the default implementation is unsynchronized.
Defined at line 152 of file ../../src/lib/callback/scoped_task_runner.h
template <class Task>
auto MakeScoped (Task task)
Defined at line 163 of file ../../src/lib/callback/scoped_task_runner.h