class UnixTaskRunner

Defined at line 60 of file ../../third_party/perfetto/include/perfetto/ext/base/unix_task_runner.h

Runs a task runner on the current thread.

Implementation note: we currently assume (and enforce in debug builds) that

Run() is called from the thread that constructed the UnixTaskRunner. This is

not strictly necessary, and we could instead track the thread that invokes

Run(). However, a related property that *might* be important to enforce is

that the destructor runs on the task-running thread. Otherwise, if there are

still-pending tasks at the time of destruction, we would destroy those

outside of the task thread (which might be unexpected to the caller). On the

other hand, the std::function task interface discourages use of any

resource-owning tasks (as the callable needs to be copyable), so this might

not be important in practice.

TODO(rsavitski): consider adding a thread-check in the destructor, after

auditing existing usages.

TODO(primiano): rename this to TaskRunnerImpl. The "Unix" part is misleading

now as it supports also Windows.

Public Methods

void UnixTaskRunner ()
void ~UnixTaskRunner ()
void Run ()

Start executing tasks. Doesn't return until Quit() is called. Run() may be

called multiple times on the same task runner.

void Quit ()
bool IsIdleForTesting ()

Checks whether there are any pending immediate tasks to run. Note that

delayed tasks don't count even if they are due to run.

void AdvanceTimeForTesting (uint32_t ms)

Pretends (for the purposes of running delayed tasks) that time advanced by

`ms`.

void PostTask (std::function<void ()> )

TaskRunner implementation:

void PostDelayedTask (std::function<void ()> , uint32_t delay_ms)
void AddFileDescriptorWatch (PlatformHandle , std::function<void ()> )
void RemoveFileDescriptorWatch (PlatformHandle )
bool RunsTasksOnCurrentThread ()
bool QuitCalled ()

Returns true if the task runner is quitting, or has quit and hasn't been

restarted since. Exposed primarily for ThreadTaskRunner, not necessary for

normal use of this class.