diff options
author | Josh Gao <jmgao@google.com> | 2017-04-12 17:00:49 -0700 |
---|---|---|
committer | Josh Gao <jmgao@google.com> | 2017-04-12 17:12:32 -0700 |
commit | 45f2f545d2af1378f3084fb01bd7ad9f5d8a003d (patch) | |
tree | d3891a2f06eb38850cfb66dbd6dd7b3c7c2f8ca4 /fdevent_test.cpp | |
parent | 50cc73ab0e3d308ff6559430cb5e0e7aff626346 (diff) | |
download | adb-45f2f545d2af1378f3084fb01bd7ad9f5d8a003d.tar.gz |
adb: kill adb_thread_{create, join, detach, exit}.
We have std::thread now, so we can delete this cruft.
Test: python test_device.py
Test: adb_test
Test: wine adb_test.exe
Test: /data/nativetest/adbd_test/adbd_test
Change-Id: Ie1c1792547b20dec45e2a62ce6515fcb981c3ef8
Diffstat (limited to 'fdevent_test.cpp')
-rw-r--r-- | fdevent_test.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/fdevent_test.cpp b/fdevent_test.cpp index c933ed5..bdb973a 100644 --- a/fdevent_test.cpp +++ b/fdevent_test.cpp @@ -21,6 +21,7 @@ #include <limits> #include <queue> #include <string> +#include <thread> #include <vector> #include "adb_io.h" @@ -77,9 +78,9 @@ struct ThreadArg { }; TEST_F(FdeventTest, fdevent_terminate) { - adb_thread_t thread; PrepareThread(); - ASSERT_TRUE(adb_thread_create([](void*) { fdevent_loop(); }, nullptr, &thread)); + + std::thread thread(fdevent_loop); TerminateThread(thread); } @@ -112,7 +113,6 @@ TEST_F(FdeventTest, smoke) { int fd_pair2[2]; ASSERT_EQ(0, adb_socketpair(fd_pair1)); ASSERT_EQ(0, adb_socketpair(fd_pair2)); - adb_thread_t thread; ThreadArg thread_arg; thread_arg.first_read_fd = fd_pair1[0]; thread_arg.last_write_fd = fd_pair2[1]; @@ -121,8 +121,7 @@ TEST_F(FdeventTest, smoke) { int reader = fd_pair2[0]; PrepareThread(); - ASSERT_TRUE(adb_thread_create(reinterpret_cast<void (*)(void*)>(FdEventThreadFunc), &thread_arg, - &thread)); + std::thread thread(FdEventThreadFunc, &thread_arg); for (size_t i = 0; i < MESSAGE_LOOP_COUNT; ++i) { std::string read_buffer = MESSAGE; @@ -152,7 +151,7 @@ static void InvalidFdEventCallback(int fd, unsigned events, void* userdata) { } } -static void InvalidFdThreadFunc(void*) { +static void InvalidFdThreadFunc() { const int INVALID_READ_FD = std::numeric_limits<int>::max() - 1; size_t happened_event_count = 0; InvalidFdArg read_arg; @@ -171,7 +170,6 @@ static void InvalidFdThreadFunc(void*) { } TEST_F(FdeventTest, invalid_fd) { - adb_thread_t thread; - ASSERT_TRUE(adb_thread_create(InvalidFdThreadFunc, nullptr, &thread)); - ASSERT_TRUE(adb_thread_join(thread)); + std::thread thread(InvalidFdThreadFunc); + thread.join(); } |