Boost named_semaphore examples?

I could not find a good example showing how to use boost :: interprocess :: named_semaphore (even on the Boost website).

I could see something about interprocess_semaphore, but they seem completely different, and I don't know if what is shown for one is related to the other.

Can someone give me some links to such examples / tutorials / documentation?

Thanks.

+4
source share
1 answer

The main difference between interprocess_semaphore and named_semaphore is that interprocess_semaphore is shared with shared memory, where named_semaphore does not need to be built (using the construct) or stored in shared memory as it refers to a name instead of anonymous.

Named synchronization methods use different objects to access the same resource, but use the same resource, where anonymous synchronization methods must share the same object in shared_memory or some other mechanism to access the same resource.

This means that named_semaphore has 3 constructors that open or create a reference synchronization method compared to interprocess_semaphore , which has only 1 constructor.

Both types of semaphore implement post , wait , try_wait and timed_wait , as expected.

Further information is available here and here .

One example of using named_semaphore is available here.

+2
source

Source: https://habr.com/ru/post/1342790/


All Articles