Skip to content

Commit b64c866

Browse files
committed
Fix Windows build
Signed-off-by: cyy <[email protected]>
1 parent b230bbd commit b64c866

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libkineto/test/LoggerObserverTest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <gtest/gtest.h>
1010
#include <memory>
11+
#include <thread>
12+
#include <vector>
1113

1214
// TODO(T90238193)
1315
// @lint-ignore-every CLANGTIDY facebook-hte-RelativeInclude
@@ -51,8 +53,8 @@ TEST(LoggerObserverTest, SingleCollectorObserver) {
5153
#define NUM_OF_WRITE_THREADS 200
5254

5355
// 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() {
5658
for (int i = 0; i < NUM_OF_MESSAGES_FOR_EACH_TYPE; i++) {
5759
LOG(INFO) << InfoTestStr;
5860
LOG(WARNING) << WarningTestStr;
@@ -73,14 +75,14 @@ TEST(LoggerObserverTest, FourCollectorObserver) {
7375
Logger::addLoggerObserver(lc4.get());
7476

7577
// Launch NUM_OF_WRITE_THREADS threads writing several messages.
76-
pthread_t ListOfThreads[NUM_OF_WRITE_THREADS];
78+
std::vector<std::thread> ListOfThreads;
7779
for (int i = 0; i < NUM_OF_WRITE_THREADS; i++) {
78-
::pthread_create(&ListOfThreads[i], nullptr, writeSeveralMessages, nullptr);
80+
ListOfThreads.emplace_back(writeSeveralMessages);
7981
}
8082

8183
// 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();
8486
}
8587

8688
auto lc1MD = lc1->extractCollectorMetadata();

0 commit comments

Comments
 (0)