proxygen
ThreadIdTest.cpp File Reference
#include <folly/system/ThreadId.h>
#include <thread>
#include <folly/portability/GTest.h>

Go to the source code of this file.

Functions

 TEST (ThreadId, getCurrentID)
 
 TEST (ThreadId, getOSThreadID)
 

Function Documentation

TEST ( ThreadId  ,
getCurrentID   
)

Definition at line 26 of file ThreadIdTest.cpp.

References EXPECT_NE, folly::getCurrentThreadID(), and uint64_t.

26  {
27  auto thisThreadID = folly::getCurrentThreadID();
28  uint64_t otherThreadID;
29  std::thread otherThread{[&] { otherThreadID = folly::getCurrentThreadID(); }};
30  otherThread.join();
31  EXPECT_NE(thisThreadID, otherThreadID);
32 }
uint64_t getCurrentThreadID()
Definition: ThreadId.h:42
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926
TEST ( ThreadId  ,
getOSThreadID   
)

Definition at line 34 of file ThreadIdTest.cpp.

References EXPECT_NE, folly::getOSThreadID(), and uint64_t.

34  {
35  auto thisThreadID = folly::getOSThreadID();
36  uint64_t otherThreadID;
37  std::thread otherThread{[&] { otherThreadID = folly::getOSThreadID(); }};
38  otherThread.join();
39  EXPECT_NE(thisThreadID, otherThreadID);
40 }
uint64_t getOSThreadID()
Definition: ThreadId.h:80
#define EXPECT_NE(val1, val2)
Definition: gtest.h:1926