|
Celeritas 0.7+960a30e
|
Receive notifications when the Geant4 application state changes. More...
#include <StateDependent.hh>

Public Member Functions | |
| StateDependent (LocalGeantStateChangeFunc cb) | |
| Construct with a stream ID and state-change callback. | |
| StateDependent (StateDependent const &)=delete | |
| StateDependent & | operator= (StateDependent const &)=delete |
| StateDependent (StateDependent &&)=delete | |
| StateDependent & | operator= (StateDependent &&)=delete |
| G4bool | Notify (G4ApplicationState state) final |
| Dispatch a state transition notification to the user callback. | |
| StreamId | local_stream () const |
| Stream that created this state dependent. | |
Receive notifications when the Geant4 application state changes.
This thread-local wrapper calls a shared user-provided function for the given worker stream whenever the simulation transitions between Geant4 application states.
G4StateManager singleton keeps a pointer (via the G4VStateDependent base constructor) to this local instance and calls delete on it when it's deleted as the run manager shuts down. Therefore this class must be deleted before G4StateManager ends.G4StateManager without checking for validity, so the destructor of this class after deleting the run manager will also crash the code.To bypass the first failure path, we use Notify to deregister ourselves when we see the run manager is about to exit or abort.
The only truly safe way to manage memory for this class is probably to leak it.
|
explicit |
Construct with a stream ID and state-change callback.