2
3
6
7
8
9
10
11
13#include <so_5/disp/mpsc_queue_traits/pub.hpp>
15#include <so_5/spinlocks.hpp>
17#include <so_5/details/invoke_noexcept_code.hpp>
20#include <condition_variable>
35
36
37
38
39
40
41
42
43
44
45
46
53 std::chrono::high_resolution_clock::duration waiting_time )
75 using clock = std::chrono::high_resolution_clock;
78 auto stop_point = clock::now() + m_waiting_time;
84 std::this_thread::yield();
95 while( stop_point > clock::now() );
102 std::unique_lock< std::mutex > mlock( m_mutex );
106 m_condition.wait( mlock, [
this]{
return m_signaled; } );
118
119
128 m_condition.notify_one();
149
150
151
152
153
154
176 std::unique_lock< std::mutex > mlock{ m_mutex, std::adopt_lock };
177 m_condition.wait( mlock, [
this]{
return m_signaled; } );
189 m_condition.notify_one();
208 return [waiting_time] {
209 return lock_unique_ptr_t{
new impl::combined_lock_t{ waiting_time } };
219 return [] {
return lock_unique_ptr_t{
new impl::simple_lock_t{} }; };
A special combined lock for queue protection.
virtual void unlock() noexcept override
Unlock object locked in exclusive mode.
virtual void wait_for_notify() noexcept override
Waiting for nofication.
combined_lock_t(std::chrono::high_resolution_clock::duration waiting_time)
virtual void notify_one() noexcept override
Notify one waiting thread if it exists.
std::condition_variable m_condition
const std::chrono::high_resolution_clock::duration m_waiting_time
default_spinlock_t m_spinlock
virtual void lock() noexcept override
Lock object in exclusive mode.
A very simple lock based on usage of std::mutex and std::condition_variable.
std::condition_variable m_condition
virtual void lock() noexcept override
Lock object in exclusive mode.
virtual void wait_for_notify() noexcept override
Waiting for nofication.
virtual void unlock() noexcept override
Unlock object locked in exclusive mode.
virtual void notify_one() noexcept override
Notify one waiting thread if it exists.
An interface for lock for MPSC queue.
Some reusable and low-level classes/functions which can be used in public header files.
Implementation details for MPSC event queue stuff.
Various stuff related to MPSC event queue implementation and tuning.
SO_5_FUNC lock_factory_t simple_lock_factory()
Factory for creation of very simple implementation based on usage of mutex and condition_variable onl...
SO_5_FUNC lock_factory_t combined_lock_factory(std::chrono::high_resolution_clock::duration waiting_time)
Factory for creation of combined queue lock with the specified waiting time.
Private part of message limit implementation.