MCPcopy Create free account
hub / github.com/apache/arrow / TEST

Function TEST

cpp/src/arrow/util/counting_semaphore_test.cc:31–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace util {
30
31TEST(CountingSemaphore, Basic) {
32#ifndef ARROW_ENABLE_THREADING
33 GTEST_SKIP() << "Test requires threading support";
34#endif
35
36 CountingSemaphore semaphore;
37 std::atomic<bool> acquired{false};
38 std::atomic<bool> started{false};
39 std::thread acquirer([&] {
40 started.store(true);
41 ASSERT_OK(semaphore.Acquire(3));
42 acquired = true;
43 });
44 ASSERT_OK(semaphore.WaitForWaiters(1));
45 ASSERT_TRUE(started.load());
46 ASSERT_FALSE(acquired.load());
47 ASSERT_OK(semaphore.Release(2));
48 SleepABit();
49 ASSERT_FALSE(acquired.load());
50 ASSERT_OK(semaphore.Release(1));
51 BusyWait(10, [&] { return acquired.load(); });
52 ASSERT_TRUE(acquired.load());
53 ASSERT_OK(semaphore.Close());
54 acquirer.join();
55}
56
57TEST(CountingSemaphore, CloseAborts) {
58#ifndef ARROW_ENABLE_THREADING

Callers

nothing calls this directly

Calls 11

SleepABitFunction · 0.85
BusyWaitFunction · 0.85
storeMethod · 0.80
emplace_backMethod · 0.80
AcquireMethod · 0.45
WaitForWaitersMethod · 0.45
loadMethod · 0.45
ReleaseMethod · 0.45
CloseMethod · 0.45
joinMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected