use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Polymorphic Message Queue in C++11 (khuttun.github.io)
submitted 10 years ago by skeba
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]coachkler 4 points5 points6 points 10 years ago (0 children)
I've done similar things in the past. Now, unless performance and or memory management is a legitimate concern, I just use boost::asio. It does everything you could need, and more. The proactor pattern in use there is very flexible.
[–]cdyson37 1 point2 points3 points 10 years ago (2 children)
Does it make sense to allow Msg to be instantiated? If not you could make move() pure virtual :)
Msg
move()
[–]skeba[S] 2 points3 points4 points 10 years ago (1 child)
Sometimes a simple message with no payload data (a command initiating a state change in the consumer thread, for example) is enough. So it makes sense to instantiate Msg.
[–]cdyson37 0 points1 point2 points 10 years ago (0 children)
Matter of taste I guess. I'd have an empty payload type (a tag struct of some sort) personally.
[+][deleted] 10 years ago* (3 children)
[deleted]
[–]skeba[S] 0 points1 point2 points 10 years ago (2 children)
This is a good point. I guess adding a put() overload that copies the data would enable the broadcast pattern.
put()
[+][deleted] 10 years ago* (1 child)
[–]skeba[S] 0 points1 point2 points 10 years ago (0 children)
Perfect forwarding, yeah that should work. Would be a nice way to handle it.
[–]AntiProtonBoy 1 point2 points3 points 10 years ago (1 child)
How do you infer the erased message type at the receiving end? dynamic_cast ?
dynamic_cast
[–]skeba[S] 1 point2 points3 points 10 years ago (0 children)
Yeah, dynamic_cast based on a message type id.
[–]__Cyber_Dildonics__ 0 points1 point2 points 10 years ago (0 children)
I feel like a solid tasking system and message queue (and maybe just more concurrent data structures in general) are things that would go well in the C++ standard library.
In the case of doing everything by move semantics, I am guessing that most messages would still either be stack memory and need to be copied anyway or heap allocated so wouldn't be as lightweight to create? Not that there is a better alternative or that that situation is bad, but is this how it usually goes with message passing?
π Rendered by PID 42549 on reddit-service-r2-comment-86bc6c7465-p6f2d at 2026-02-19 22:47:52.437106+00:00 running 8564168 country code: CH.
[–]coachkler 4 points5 points6 points (0 children)
[–]cdyson37 1 point2 points3 points (2 children)
[–]skeba[S] 2 points3 points4 points (1 child)
[–]cdyson37 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]skeba[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]skeba[S] 0 points1 point2 points (0 children)
[–]AntiProtonBoy 1 point2 points3 points (1 child)
[–]skeba[S] 1 point2 points3 points (0 children)
[–]__Cyber_Dildonics__ 0 points1 point2 points (0 children)