7

I am looking for something analogous to CreateEvent(), SetEvent() and WaitForMultipleObjects() from the Win32 world.

Specifically this has to be accessible across processes on the same machine.

We are already using Poco for some cross platform stuff, but I don't see that the Poco::Event is what I want. perhaps i am missing something.

EDIT:

To explain what I want to do:

I want process B to know when something happens in process A. This is trivial in win32 - Each process/thread calls CreateEvent() with a name for the event. Process B calls waitForXObject() and Process A calls SetEvent() when something happens. B is signaled.

Again, this is trivial in win32, but how to do it cross-platform.

Tim
  • 20,184
  • 24
  • 117
  • 214
  • Can you explain more what you are trying to do ? There is no C++ equivalent, there are libraries out there that might work for you. It sounds to me that what you might need is some middleware to put your stuff on (Of course I am guessing) – Romain Hippeau Apr 19 '10 at 02:40
  • @Romain - I added details. I know that there are no C++ primitives. What I am looking for are ways to do it IN C++, not a language change. – Tim Apr 19 '10 at 03:09
  • 1
    See my answer you want boost::named_condition, there is no built in c++ way to do this without a library like boost. – Brian R. Bondy Apr 19 '10 at 03:13
  • I understand there is no way in C++ - that is why I looked at Poco. It is not obvious to me how to do it with boost - how do you "name" the events/signals/conditions? – Tim Apr 19 '10 at 03:15
  • Oh - now I see the "named" part. thanks – Tim Apr 19 '10 at 03:16
  • You can do this cross platform with C++11. Here is the example: https://github.com/moya-lang/Event – no one special Mar 09 '19 at 12:11

3 Answers3

4

There is no built in way in C++ to do named events. But you can use boost to do it.

You're looking for boost::condition and boost::named_condition

As you also mentioned there exists: Poco.NamedEvent

Brian R. Bondy
  • 339,232
  • 124
  • 596
  • 636
2

boost has a number of cross platform threading primitives like this.

look at boost:mutex

Actually, look at Cross-Platform equivalent to windows events

Community
  • 1
  • 1
Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
  • I had seen that when i searched SO initially before posting - but did not see a way to "Name" the events in that answer. – Tim Apr 19 '10 at 03:24
  • Conclusion from that thread: boost or Qt, whichever you prefer – Pieter May 08 '10 at 13:35
1

oops - After seeing Brian's answer about named events it seems I missed Poco's solution:

http://pocoproject.org/docs/Poco.NamedEvent.html

I had only seen Poco.Event

We'll probably use that since it seems to be simpler and lighter weight in the client code.

Tim
  • 20,184
  • 24
  • 117
  • 214