Order of execution in startup.scd

In my startup.scd I have

s.waitForBoot {
  s.volume.gui;
  StageMaster.activate(numChannels: 2, compThreshold: 0.7, limiterLevel: 1.0, highEndDb: 3.0);
  ServerMeter.new(s, 0, 2);
};

where StageMaster is a quark (code) that adds itself to the tail of the server nodes and it takes a little time doing so. As a result the ServerMeter ends up in the node tree before the StageMaster.

How can I ensure it gets added at the end? I tried

s.wait( StageMaster.activate(numChannels: 2, compThreshold: 0.7, limiterLevel: 1.0, highEndDb: 3.0));

but that did not work.

Stage master would need to be altered to return a Condition, or some other type of awaitable. Without querying the server graph, I don’t think it is possible to do it nicely…

…you could always just assume it will finish within a certain amount of time, it is a little silly and ugly, but will work 99% of the time.

s.waitForBoot {
  s.volume.gui;
  StageMaster.activate(numChannels: 2, compThreshold: 0.7, limiterLevel: 1.0, highEndDb: 3.0);
  1.0.wait; // ugly
  ServerMeter.new(s, 0, 2);
};

There was a big discussion recently about async behaviour, that concluded suggesting a way forward using a promise type.

Ugly but works! And I can patch StageMaster later. Thank you.