c++ - Is this the right approach for a thread-safe Queue class? -
I am thinking that this is the right way to write thread-safe queues in C ++?
template & lt; Class T & gt; Square line {public: q () {} zero push (t & a) {m_mutex.lock (); M_q.push_back (a); M_mutex.unlock (); } T & amp; Pop () {m_mutex.lock (); T & amp; Temp = m_q.pop (); M_mutex.unlock (); Return temporary; } Private: std :: queue & lt; T & gt; M_q; Promotion: Mute x m_mutex; };
You get this idea ... I'm just thinking that this is the best way thank you!
Edit: The question I am getting is, I want to make it clear that Mute X Promotions: Mute X
single Consumer queue implementation (which had improved on the implementation published last month.)
On the same concurrent subjects, with a full-fledged discussion of possible losses and performance issues as well as dealing with a more general viewpoint for a multi-user concurrent queue in the issue.
Enjoy.
Comments
Post a Comment