From 87527179bbdbab1246b7f6a96606b5acffcc60be Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 5 Sep 2023 14:36:08 +0200 Subject: [PATCH] Allow sorting StateChange callbacks If the key of the callback is a number, it will be used to invoke callbacks with the correct ordering. --- fairmq/StateMachine.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fairmq/StateMachine.cxx b/fairmq/StateMachine.cxx index 56668dea..cc2ee6eb 100644 --- a/fairmq/StateMachine.cxx +++ b/fairmq/StateMachine.cxx @@ -310,7 +310,9 @@ try { void StateMachine::SubscribeToStateChange(const string& key, function callback) { - static_pointer_cast(fFsm)->fStateChangeSignalsMap.insert({key, static_pointer_cast(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(fFsm)->fStateChangeSignalsMap.insert({key, static_pointer_cast(fFsm)->fStateChangeSignal.connect(i, callback)}); } void StateMachine::UnsubscribeFromStateChange(const string& key)