Is there a C++ cross platform “named event like th

2019-03-27 13:47发布

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.

4条回答
成全新的幸福
2楼-- · 2019-03-27 14:22

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.

查看更多
Melony?
3楼-- · 2019-03-27 14:27

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

查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-03-27 14:27

You can do this cross platform with C++11. Here is the example: https://github.com/moya-lang/Event

查看更多
干净又极端
5楼-- · 2019-03-27 14:30

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

look at boost:mutex

Actually, look at Cross-Platform equivalent to windows events

查看更多
登录 后发表回答