From: Christopher Dykes Date: Mon, 1 Aug 2016 20:17:30 +0000 (-0700) Subject: Switch some assertions to std::thread rather than pthread X-Git-Tag: v2016.08.08.00~44 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=800802c8573781c591c39d4ea580938a9cd2e8a0;p=folly.git Switch some assertions to std::thread rather than pthread Summary: Because the check macros attempt to pipe the values to the error stream, but we can't do that with the Windows implementation. Switch to `std::this_thread::get_id()` instead because it's standard and can be piped. Reviewed By: djwatson Differential Revision: D3650362 fbshipit-source-id: 8af65448a33949f310abc818d95bac843214b685 --- diff --git a/folly/io/async/test/AsyncSocketTest2.cpp b/folly/io/async/test/AsyncSocketTest2.cpp index 5e548c1e..9876da6c 100644 --- a/folly/io/async/test/AsyncSocketTest2.cpp +++ b/folly/io/async/test/AsyncSocketTest2.cpp @@ -1949,18 +1949,18 @@ TEST(AsyncSocketTest, OtherThreadAcceptCallback) { // Add several accept callbacks TestAcceptCallback cb1; - auto thread_id = pthread_self(); + auto thread_id = std::this_thread::get_id(); cb1.setAcceptStartedFn([&](){ - CHECK_NE(thread_id, pthread_self()); - thread_id = pthread_self(); + CHECK_NE(thread_id, std::this_thread::get_id()); + thread_id = std::this_thread::get_id(); }); cb1.setConnectionAcceptedFn( [&](int /* fd */, const folly::SocketAddress& /* addr */) { - CHECK_EQ(thread_id, pthread_self()); + CHECK_EQ(thread_id, std::this_thread::get_id()); serverSocket->removeAcceptCallback(&cb1, nullptr); }); cb1.setAcceptStoppedFn([&](){ - CHECK_EQ(thread_id, pthread_self()); + CHECK_EQ(thread_id, std::this_thread::get_id()); }); // Test having callbacks remove other callbacks before them on the list,