Switch some assertions to std::thread rather than pthread
authorChristopher Dykes <cdykes@fb.com>
Mon, 1 Aug 2016 20:17:30 +0000 (13:17 -0700)
committerFacebook Github Bot 2 <facebook-github-bot-2-bot@fb.com>
Mon, 1 Aug 2016 20:23:29 +0000 (13:23 -0700)
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

folly/io/async/test/AsyncSocketTest2.cpp

index 5e548c1e2d7dc28e8ba9d16eab255f4843fbe7bb..9876da6c98d665e9c5fdbd6e5928d83410ea3d5a 100644 (file)
@@ -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,