khuttun / polym Goto Github PK
View Code? Open in Web Editor NEWPolyM is a very simple C++ message queue intended for inter-thread communication
License: MIT License
PolyM is a very simple C++ message queue intended for inter-thread communication
License: MIT License
Hi,
First thank you for the hard work. Very interesting to see clean code with pimpl.
I have few suggestions for your library though. Each of them deserve a PR I can make.
Lines 30 to 38 in f97db66
Lines 44 to 50 in f97db66
I think a try_get could be really useful:
/**
* Get message from the head of the queue. Returns an empty pointer if no
* message is available.
*/
std::unique_ptr<Msg> try_get();
Lines 57 to 59 in f97db66
Thank you again for this wonderful piece of code!
BR
it s became the foundation for message passing , it s work really great!!
An idea to greatly improve performance would be a CircularQueue type.
Performance of circular buffer is an order of magnitude faster that the deque container used by STL (underlying container of std::queue) as per the following benchmark (consider case with vector with reserve() as the vector is pre-allocated):
Benchmark
One example is the use in the spdlog lib : spdlog
Its using a fixed size std::vector and add the interface for circular buffer around it.
Would it be possible to mark move operations in Msg and DataMsg deleted and implement the moving by hand in the virtual move() functions?
Hi,
I'm having a problem with using DataMsg template nested inside another DataMsg, like this: DataMsg<DataMsg<int>>
My use case is to extract the nested DataMsg and pass it on to another class. As I do not know the actual data type of DataMsg yet, I'm starting by casting to the base Msg type like this:
function(Msg &base) {
dynamic_cast<DataMsg<Msg>&>(base)
}
However, this cast fails with a bad cast exception. Doing the same using a static cast seems to work as expected (payload OK, no segfault).
From a polymorphic view point I can't see anything wrong with my approach. As dynamic casting works for the non-nested type, it should work for the nested one too?
Any ideas?
Thanks!
I've attached a minimalistic test program that shows the problem. This uses the Msg and DataMsg type with everyting removed that is not essential.
Build and run with
g++ test.cpp -o test.x && ./test.x
Hello,
it is not an issue it s only a message to say that the impl is really good, thanks you.
regards,
david G.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.