Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit a8a09f2

Browse files
committed
Add test to ensure that concurrent message loops have at least one workers.
The current count is determined from std::thread::hardware_concurrency which can return zero. Even in such cases, the implementation may not return a loop with no workers. There are numerous components that depend on having non-zero workers in the queue.
1 parent 86682a2 commit a8a09f2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fml/message_loop_unittests.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@ TEST(MessageLoop, TaskObserverFire) {
284284
ASSERT_TRUE(terminated);
285285
}
286286

287+
TEST(MessageLoop, ConcurrentMessageLoopHasNonZeroWorkers) {
288+
auto loop = fml::ConcurrentMessageLoop::Create(
289+
0u /* explicitly specify zero workers */);
290+
ASSERT_GT(loop->GetWorkerCount(), 0u);
291+
}
292+
287293
TEST(MessageLoop, CanCreateAndShutdownConcurrentMessageLoopsOverAndOver) {
288294
for (size_t i = 0; i < 10; ++i) {
289295
auto loop = fml::ConcurrentMessageLoop::Create(i + 1);

0 commit comments

Comments
 (0)