class RealLoop

Defined at line 38 of file ../../sdk/lib/async-loop-testing/cpp/include/lib/async-loop/testing/cpp/real_loop.h

A class which sets up a |async::Loop| and offers a variety of ways to run

the loop until a certain condition is satisfied.

Example:

// Creates a fixture that creates a message loop on this thread.

class FooTest : public ::testing::Test, public loop_fixture::RealLoop {};

TEST_F(FooTest, TestCase) {

// Schedule asynchronous operations, and quit the loop when done.

DoSomeAsyncWork([

&

] { QuitLoop(); });

// Run the loop until it is quit.

RunLoop();

// Check results of those asynchronous operations here.

}

Protected Methods

void RealLoop ()

Defined at line 46 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

void ~RealLoop ()

Defined at line 48 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

async_dispatcher_t * dispatcher ()

Returns the loop's asynchronous dispatch interface.

Defined at line 50 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

void RunLoop ()

Runs the loop until it is exited.

Defined at line 52 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

bool RunLoopWithTimeout (zx::duration timeout)

Runs the loop for at most |timeout|. Returns |true| if the timeout has been

reached.

Defined at line 57 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

void RunLoopUntil (fit::function<bool ()> condition, zx::duration step)

Runs the loop until the condition returns true.

|step| specifies the interval at which this method should wake up to poll

|condition|. If |step| is |zx::duration::infinite()|, no polling timer is

set. Instead, the condition is checked initially and after anything happens

on the loop (e.g. a task executes). This is useful when the caller knows

that |condition| will be made true by a task running on the loop. This will

generally be the case unless |condition| is made true on a different

thread.

Defined at line 85 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

bool RunLoopWithTimeoutOrUntil (fit::function<bool ()> condition, zx::duration timeout, zx::duration step)

Runs the loop until the condition returns true or the timeout is reached.

Returns |true| if the condition was met, and |false| if the timeout was

reached.

|step| specifies the interval at which this method should wake up to poll

|condition|. If |step| is |zx::duration::infinite()|, no polling timer is

set. Instead, the condition is checked initially and after anything happens

on the loop (e.g. a task executes). This is useful when the caller knows

that |condition| will be made true by a task running on the loop. This will

generally be the case unless |condition| is made true on a different

thread.

Defined at line 61 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

void RunLoopUntilIdle ()

Runs the message loop until idle.

Defined at line 89 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

template <typename Callable>
auto PerformBlockingWork (Callable && work)

Runs the message loop while spawning a new thread to perform |work|, and

returns the result of calling |work|. Runs the loop until |work| returns.

|Callable| should take zero arguments.

Defined at line 93 of file ../../sdk/lib/async-loop-testing/cpp/include/lib/async-loop/testing/cpp/real_loop.h

template <typename PromiseType>
typename PromiseType::result_type RunPromise (PromiseType promise)

Internal template implementation details

========================================

Defined at line 131 of file ../../sdk/lib/async-loop-testing/cpp/include/lib/async-loop/testing/cpp/real_loop.h

void QuitLoop ()

Quits the loop.

Defined at line 94 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

fit::closure QuitLoopClosure ()

Creates a closure that quits the test message loop when executed.

Defined at line 96 of file ../../sdk/lib/async-loop-testing/cpp/real_loop.cc

async::Loop & loop ()

Defined at line 114 of file ../../sdk/lib/async-loop-testing/cpp/include/lib/async-loop/testing/cpp/real_loop.h