8
8
9
9
#include < gtest/gtest.h>
10
10
#include < memory>
11
+ #include < thread>
12
+ #include < vector>
11
13
12
14
// TODO(T90238193)
13
15
// @lint-ignore-every CLANGTIDY facebook-hte-RelativeInclude
@@ -51,8 +53,8 @@ TEST(LoggerObserverTest, SingleCollectorObserver) {
51
53
#define NUM_OF_WRITE_THREADS 200
52
54
53
55
// Writes NUM_OF_MESSAGES_FOR_EACH_TYPE messages for each INFO, WARNING, and
54
- // ERROR. NOLINTNEXTLINE(clang-diagnostic-unused-parameter)
55
- void * writeSeveralMessages (void * ptr ) {
56
+ // ERROR.
57
+ void * writeSeveralMessages () {
56
58
for (int i = 0 ; i < NUM_OF_MESSAGES_FOR_EACH_TYPE; i++) {
57
59
LOG (INFO) << InfoTestStr;
58
60
LOG (WARNING) << WarningTestStr;
@@ -73,14 +75,14 @@ TEST(LoggerObserverTest, FourCollectorObserver) {
73
75
Logger::addLoggerObserver (lc4.get ());
74
76
75
77
// Launch NUM_OF_WRITE_THREADS threads writing several messages.
76
- pthread_t ListOfThreads[NUM_OF_WRITE_THREADS] ;
78
+ std::vector<std::thread> ListOfThreads;
77
79
for (int i = 0 ; i < NUM_OF_WRITE_THREADS; i++) {
78
- ::pthread_create (& ListOfThreads[i], nullptr , writeSeveralMessages, nullptr );
80
+ ListOfThreads. emplace_back ( writeSeveralMessages);
79
81
}
80
82
81
83
// Wait for all threads to finish.
82
- for (int i = 0 ; i < NUM_OF_WRITE_THREADS; i++ ) {
83
- ::pthread_join (ListOfThreads[i], nullptr );
84
+ for (auto & thread: ListOfThreads ) {
85
+ thread. join ( );
84
86
}
85
87
86
88
auto lc1MD = lc1->extractCollectorMetadata ();
0 commit comments