-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
issue #3996: impl gettid for macOS & cygwin64.
- Loading branch information
Showing
4 changed files
with
59 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// Copyright (c) 2013-2024 The SRS Authors | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
#include <srs_utest_thread_pool.hpp> | ||
#include <pthread.h> | ||
|
||
static srs_error_t dummy_loop(void*) { | ||
return srs_success; | ||
} | ||
|
||
|
||
VOID TEST(ThreadPoolTest, tid) { | ||
SrsThreadPool* thread_pool_1 = new SrsThreadPool(); | ||
SrsThreadPool* thread_pool_2 = new SrsThreadPool(); | ||
|
||
EXPECT_TRUE(thread_pool_1->execute("hybrid", dummy_loop, (void*)NULL) == srs_success); | ||
EXPECT_TRUE(thread_pool_2->execute("hybrid", dummy_loop, (void*)NULL) == srs_success); | ||
usleep(100); | ||
|
||
EXPECT_GT(thread_pool_1->hybrid()->tid, 0); | ||
EXPECT_GT(thread_pool_2->hybrid()->tid, 0); | ||
|
||
EXPECT_NE(thread_pool_1->hybrid()->tid, thread_pool_2->hybrid()->tid); | ||
|
||
SrsThreadEntry* thread_entry_1 = thread_pool_1->hybrid(); | ||
SrsThreadEntry* thread_entry_2 = thread_pool_2->hybrid(); | ||
|
||
// Workaround SrsThreadEntry Memory leak in SrsThreadPool, Maybe SrsThreadPool need to improve. | ||
srs_freep(thread_entry_1); | ||
srs_freep(thread_entry_2); | ||
|
||
srs_freep(thread_pool_1); | ||
srs_freep(thread_pool_2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// Copyright (c) 2013-2024 The SRS Authors | ||
// | ||
// SPDX-License-Identifier: MIT | ||
// | ||
|
||
#ifndef SRS_UTEST_THREAD_POOL | ||
#define SRS_UTEST_THREAD_POOL | ||
|
||
#include <srs_utest.hpp> | ||
|
||
#include <srs_app_threads.hpp> | ||
|
||
#endif // SRS_UTEST_THREAD_POOL | ||
|