1010#include < utility>
1111#include < vector>
1212
13- #ifdef ARCANA_TESTING_HOOKS
13+ #ifdef ARCANA_TEST_HOOKS
1414#include < functional>
1515#endif
1616
1717namespace 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