|
| onur (49) | |||||||
| Hello, I want to create a MessageQueue class. My current interface looks like this:
This class sets up the queue. The getReceiver/getSender methods provide two interfaces (since the sender should not be able to receive it's own messages). For the Receiver/Sender class to access the queue I use a reference to the creating MessagePipe.
If I know want to initalize the Receiver member of MessagePipe with a reference to the MessagePipe I receive an error stating that I use *this before the object is completely constructed:
I think this should be no problem since the members cannot be accessed before the construction and only store the reference. I could create the sender/receiver interfaces dynamically after initialization step but I don't think that would be a good solution. Anybody got a good idea? | |||||||
| PanGalactic (778) | |
| What's with all the private/friend business? That's moving from the realm of bondage and discipline into sado-masochism. Constraining the message pipe to not permit the sender and receiver to be the same is silly. There are plenty of legitimate use cases for that. Another thing: friendship is not inheritable so these are not "interfaces" at all. Look at the Python Queue implementation for a good way to do message pipes. | |
| writetonsharma (832) | |
| See ACE_Message_queue implementation for some good ideas. Adaptive Communication Environment, a C++ library. | |
| PanGalactic (778) | |
| writetonsharma is right -- don't re-invent the wheel. Most people have already written most of the infrastructure components for you. | |
| onur (49) | |
| I kicked the friend part and also the separate interfaces for sender/receiver. I don't need a very sophisticated solution and since my version does now exactly what I want, I'll stick with it. If the requirements should change, for example multiple senders/receivers ..., I'll switch to something like ACE. Tanks for the advice! | |
This topic is archived - New replies not allowed.
