Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Safir::Utilities::StartupSynchronizer Class Reference

This class can be used to synchronize creation and opening of a resource that is shared between multiple processes and threads. More...

#include <Safir/Utilities/StartupSynchronizer.h>

Inheritance diagram for Safir::Utilities::StartupSynchronizer:
Collaboration diagram for Safir::Utilities::StartupSynchronizer:

Public Member Functions

 StartupSynchronizer (const char *uniqueName)
 Construct a StartupSynchronizer for a resource with a given name. More...
 
 ~StartupSynchronizer ()
 Destructor. More...
 
void Start (Synchronized *const synchronized)
 Call this to start the synchronized startup. More...
 

Detailed Description

This class can be used to synchronize creation and opening of a resource that is shared between multiple processes and threads.

The resource has to have a unique name, and the basic idea is that: One and only one call to Start will generate a Create() callback. All instances (including the Creator) will get a Use() callback when the create has completed. The last instance of StartupSynchronizer to be destroyed will generate a Destroy callback.

Note that multiple threads within a process may call these functions simultaneously on different instances with different arguments to no ill effect.

Constructor & Destructor Documentation

Safir::Utilities::StartupSynchronizer::StartupSynchronizer ( const char *  uniqueName)
explicit

Construct a StartupSynchronizer for a resource with a given name.

Safir::Utilities::StartupSynchronizer::~StartupSynchronizer ( )

Destructor.

Stop using the shared resource. If this instance is the last user of the resource the Destroy callback will probably be called (see Synchronized class documentation).

Member Function Documentation

void Safir::Utilities::StartupSynchronizer::Start ( Synchronized *const  synchronized)

Call this to start the synchronized startup.

The callbacks to synchronized will be called as described in the Synchronized class documentation.

Only one call to Start is allowed for a particular instance. Multiple calls result in undefined behaviour.

Multiple calls to different instances of this class with the same pointer argument also results in undefined behaviour.