Skip to content

Commit 74233c3

Browse files
committed
Boost synchronized queues
1 parent 2324d10 commit 74233c3

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cpp/patterns.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ struct Change_interface
126126
template <typename ValueType>
127127
class Synchronized_encapsulated_value
128128
/**
129-
@brief [encapsulating](https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)) class with only public accessor and [mutator](https://en.wikipedia.org/wiki/Mutator_method) intrfaces
129+
@brief [encapsulating](https://en.wikipedia.org/wiki/Encapsulation_(computer_programming))
130+
class with only public accessor and [mutator](https://en.wikipedia.org/wiki/Mutator_method) intrfaces
130131
131132
Classes by default are private. This class doesn't contain public members.
132133
*/
@@ -832,6 +833,14 @@ void architectural_patterns_demo()
832833

833834
template <typename T, class Container = queue<T>>
834835
class Synchronized_queue
836+
/**
837+
See also
838+
- [Boost synchronized queues](https://www.boost.org/doc/libs/release/doc/html/thread/sds.html#thread.sds.synchronized_queues)
839+
- [boost/thread/concurrent_queues/sync_queue.hpp](https://github.com/boostorg/thread/blob/HEAD/include/boost/thread/concurrent_queues/sync_queue.hpp)
840+
- [boost/thread/concurrent_queues/detail/sync_queue_base.hpp](https://github.com/boostorg/thread/blob/HEAD/include/boost/thread/concurrent_queues/detail/sync_queue_base.hpp)
841+
842+
Warning: unbounded synchronized queues can cause [OOM](https://en.wikipedia.org/wiki/Out_of_memory)
843+
*/
835844
: Container {
836845
mutex mtx;
837846
bool stoped = false;
@@ -900,7 +909,7 @@ struct Active_object
900909
}
901910

902911
protected:
903-
Synchronized_queue<Command> cmd_q;
912+
Synchronized_queue<Command> cmd_q; // BTW, Circular buffer is more durable because it doesn't cause OOM
904913
thread th;
905914
};
906915

0 commit comments

Comments
 (0)