1// Copyright 2017 The Fuchsia Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include <lib/async-loop/cpp/loop.h> 6 7#include <zircon/assert.h> 8 9namespace async { 10 11Loop::Loop(const async_loop_config_t* config) { 12 zx_status_t status = async_loop_create(config, &loop_); 13 ZX_ASSERT_MSG(status == ZX_OK, "status=%d", status); 14} 15 16Loop::~Loop() { 17 async_loop_destroy(loop_); 18} 19 20void Loop::Shutdown() { 21 async_loop_shutdown(loop_); 22} 23 24zx_status_t Loop::Run(zx::time deadline, bool once) { 25 return async_loop_run(loop_, deadline.get(), once); 26} 27 28zx_status_t Loop::RunUntilIdle() { 29 return async_loop_run_until_idle(loop_); 30} 31 32void Loop::Quit() { 33 async_loop_quit(loop_); 34} 35 36zx_status_t Loop::ResetQuit() { 37 return async_loop_reset_quit(loop_); 38} 39 40async_loop_state_t Loop::GetState() const { 41 return async_loop_get_state(loop_); 42} 43 44zx_status_t Loop::StartThread(const char* name, thrd_t* out_thread) { 45 return async_loop_start_thread(loop_, name, out_thread); 46} 47 48void Loop::JoinThreads() { 49 async_loop_join_threads(loop_); 50} 51 52} // namespace async 53