The major difference between interprocess_semaphore
and named_semaphore
is that the interprocess_semaphore
is shared with using the shared memory ,where as named_semaphore
doesn't need to be constructed (using construct) or stored in shared memory as it referenced by name instead of anonymously.
Named synchronization methods use different objects to access the same resource, but are using the same resource, where is anonymous synchronization methods need to share the same object in shared_memory or some other mechanism in order to access the same resource.
This means that named_semaphore
has 3 constructors which either open or create the referenced synchronization method, in comparison to interprocess_semaphore
which only has 1 constructor.
Both semaphore types implement post
, wait
, try_wait
and timed_wait
as expected.
Further information is available here and here.
One example of using a named_semaphore
is available here