Skip to content

Commit b9bf9d8

Browse files
authored
Rename testing hooks for consistency and clarity (#60)
1 parent cf977a0 commit b9bf9d8

1 file changed

Lines changed: 19 additions & 16 deletions

File tree

Source/Shared/arcana/threading/blocking_concurrent_queue.h

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,27 @@
1010
#include <utility>
1111
#include <vector>
1212

13-
#ifdef ARCANA_TESTING_HOOKS
13+
#ifdef ARCANA_TEST_HOOKS
1414
#include <functional>
1515
#endif
1616

1717
namespace arcana
1818
{
19-
#ifdef ARCANA_TESTING_HOOKS
20-
namespace detail
19+
#ifdef ARCANA_TEST_HOOKS
20+
namespace test_hooks::blocking_concurrent_queue
2121
{
22-
inline std::function<void()> beforeWaitCallback{[]() {}};
23-
}
22+
namespace detail
23+
{
24+
inline std::function<void()> beforeWaitCallback{[]() {}};
25+
}
2426

25-
// Set a callback to be invoked while holding the queue mutex, right before
26-
// condition_variable::wait(). This is used for deterministic testing of
27-
// lost-wakeup race conditions. Pass an empty lambda [](){} to reset.
28-
inline void set_before_wait_callback(std::function<void()> callback)
29-
{
30-
detail::beforeWaitCallback = std::move(callback);
27+
// Set a callback to be invoked while holding the queue mutex, right before
28+
// condition_variable::wait(). This is used for deterministic testing of
29+
// lost-wakeup race conditions. Pass an empty lambda [](){} to reset.
30+
inline void set_before_wait_callback(std::function<void()> callback)
31+
{
32+
detail::beforeWaitCallback = std::move(callback);
33+
}
3134
}
3235
#endif
3336

@@ -117,8 +120,8 @@ namespace arcana
117120
{
118121
while (!cancel.cancelled() && m_data.empty())
119122
{
120-
#ifdef ARCANA_TESTING_HOOKS
121-
detail::beforeWaitCallback();
123+
#ifdef ARCANA_TEST_HOOKS
124+
test_hooks::blocking_concurrent_queue::detail::beforeWaitCallback();
122125
#endif
123126
m_dataReady.wait(lock);
124127
}
@@ -141,8 +144,8 @@ namespace arcana
141144
{
142145
while (!cancel.cancelled() && m_data.empty())
143146
{
144-
#ifdef ARCANA_TESTING_HOOKS
145-
detail::beforeWaitCallback();
147+
#ifdef ARCANA_TEST_HOOKS
148+
test_hooks::blocking_concurrent_queue::detail::beforeWaitCallback();
146149
#endif
147150
m_dataReady.wait(lock);
148151
}
@@ -164,4 +167,4 @@ namespace arcana
164167
mutable std::mutex m_mutex;
165168
std::condition_variable m_dataReady;
166169
};
167-
}
170+
}

0 commit comments

Comments
 (0)