Skip to content

Commit

Permalink
Allow sorting StateChange callbacks
Browse files Browse the repository at this point in the history
If the key of the callback is a number, it will be used to invoke
callbacks with the correct ordering.
  • Loading branch information
ktf authored and rbx committed Sep 6, 2023
1 parent c3418cc commit 3c1723f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fairmq/StateMachine.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,9 @@ try {

void StateMachine::SubscribeToStateChange(const string& key, function<void(const State)> callback)
{
static_pointer_cast<FairMQFSM>(fFsm)->fStateChangeSignalsMap.insert({key, static_pointer_cast<FairMQFSM>(fFsm)->fStateChangeSignal.connect(callback)});
// Check if the key has a integer value as prefix, if yes, decode it.
int i = strtol(key.c_str(), nullptr, 10);
static_pointer_cast<FairMQFSM>(fFsm)->fStateChangeSignalsMap.insert({key, static_pointer_cast<FairMQFSM>(fFsm)->fStateChangeSignal.connect(i, callback)});
}

void StateMachine::UnsubscribeFromStateChange(const string& key)
Expand Down

0 comments on commit 3c1723f

Please sign in to comment.