add zx::event
Change-Id: Id41044b2a53b37095ea22f96f7b2d9a30442a687
diff --git a/zircon/system/core/devmgr/devcoordinator/coordinator.cpp b/zircon/system/core/devmgr/devcoordinator/coordinator.cpp
index 47afed6..97e1b2f 100644
--- a/zircon/system/core/devmgr/devcoordinator/coordinator.cpp
+++ b/zircon/system/core/devmgr/devcoordinator/coordinator.cpp
@@ -708,7 +708,7 @@
// more tied to devhost teardown than it is.
if (parent->test_state() == Device::TestStateMachine::kTestUnbindSent) {
- zx_object_signal(parent->test_event, 0, TEST_REMOVE_DONE_SIGNAL);
+ parent->test_event.signal(0, TEST_REMOVE_DONE_SIGNAL);
if (!(dev->flags & DEV_CTX_PROXY)) {
// remove from list of all devices
devices_.erase(*dev);
diff --git a/zircon/system/core/devmgr/devcoordinator/device.cpp b/zircon/system/core/devmgr/devcoordinator/device.cpp
index 39142e6..19bf310 100644
--- a/zircon/system/core/devmgr/devcoordinator/device.cpp
+++ b/zircon/system/core/devmgr/devcoordinator/device.cpp
@@ -409,7 +409,7 @@
real_parent->DriverCompatibiltyTest(drivername);
break;
} else if (real_parent->test_state() == Device::TestStateMachine::kTestBindSent) {
- zx_object_signal(real_parent->test_event, 0, TEST_BIND_DONE_SIGNAL);
+ real_parent->test_event.signal(0, TEST_BIND_DONE_SIGNAL);
break;
}
}
@@ -510,7 +510,7 @@
test_drivername);
return ZX_ERR_INTERNAL;
}
- zx_status_t status = zx_event_create(0, &test_event);
+ zx_status_t status = zx::event::create(0, &test_event);
if (status != ZX_OK) {
log(ERROR,
"devcoordinator: Driver Compatibility test failed for %s: "
@@ -520,8 +520,7 @@
}
auto cleanup = fbl::MakeAutoCall([this]() {
- zx_handle_close(this->test_event);
- test_event = ZX_HANDLE_INVALID;
+ test_event.reset();
set_test_state(Device::TestStateMachine::kTestDone);
});
@@ -540,10 +539,11 @@
}
this->set_test_state(Device::TestStateMachine::kTestUnbindSent);
- uint32_t observed = 0;
+ zx_signals_t observed = 0;
// Now wait for the device to be removed.
- status = zx_object_wait_one(this->test_event, TEST_REMOVE_DONE_SIGNAL,
- zx_deadline_after(ZX_SEC(20)), &observed);
+ status = test_event.wait_one(TEST_REMOVE_DONE_SIGNAL,
+ zx::time(zx_deadline_after(ZX_SEC(20))),
+ &observed);
if (status != ZX_OK) {
if (status == ZX_ERR_TIMED_OUT) {
// The Remove did not complete.
@@ -564,8 +564,9 @@
observed = 0;
this->coordinator->HandleNewDevice(fbl::WrapRefPtr(this));
this->set_test_state(Device::TestStateMachine::kTestBindSent);
- status = zx_object_wait_one(this->test_event, TEST_BIND_DONE_SIGNAL,
- zx_deadline_after(ZX_SEC(20)), &observed);
+ status = test_event.wait_one(TEST_BIND_DONE_SIGNAL,
+ zx::time(zx_deadline_after(ZX_SEC(20))),
+ &observed);
if (status != ZX_OK) {
if (status == ZX_ERR_TIMED_OUT) {
// The Bind did not complete.
diff --git a/zircon/system/core/devmgr/devcoordinator/device.h b/zircon/system/core/devmgr/devcoordinator/device.h
index 6c9d675..cd5bf55 100644
--- a/zircon/system/core/devmgr/devcoordinator/device.h
+++ b/zircon/system/core/devmgr/devcoordinator/device.h
@@ -15,6 +15,7 @@
#include <lib/async/cpp/task.h>
#include <lib/async/cpp/wait.h>
#include <lib/zx/channel.h>
+#include <lib/zx/event.h>
#include <variant>
#include "composite-device.h"
@@ -366,7 +367,7 @@
test_state_ = new_state;
}
char test_drivername[fuchsia_device_MAX_DRIVER_NAME_LEN + 1] = {0};
- zx_handle_t test_event = ZX_HANDLE_INVALID;
+ zx::event test_event;
private:
zx_status_t HandleRead();
int RunCompatibilityTests();