-
Notifications
You must be signed in to change notification settings - Fork 761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Split duties between Server and ServerProcess #3310
Comments
Yay, got user accessible conditions and doWhenBooted working nicely now: (
s.quit;
"XYZ".do { |char, i|
Routine {
"% is waiting for booted ...\n".postf(char);
s.process.hasBootedCondition.wait;
"% is waiting for server to be ready ...\n".postf(char);
s.process.isReadyCondition.wait;
3.do { [" ", i, char].join($ ).postln; 0.1.wait };
"% is waiting for server to quit ...\n".postf(char);
s.process.hasQuitCondition.wait;
"% ends.\n".postf(char);
}.play;
};
)
s.boot;
-> X is waiting for server to be ready ...
Y is waiting for server to be ready ...
Z is waiting for server to be ready ...
*** server localhost is ready after 0.2535 secs!
0 X
1 Y
2 Z
0 X
1 Y
2 Z
0 X
1 Y
2 Z
X is waiting for server to quit ...
Y is waiting for server to quit ...
Z is waiting for server to quit ...
s.quit; // trigger ends
-> localhost
X ends.
Y ends.
Z ends.
(
s.quit;
s.doWhenBooted({ "AAA".postln; });
s.doWhenBooted({ "BBB".postln; });
s.doWhenBooted({ "CCC".postln; });
// raw waiting routines run first
"XYZ".do { |char, i|
Routine {
"% is waiting for server to be ready ...\n".postf(char);
s.process.isReadyCondition.wait;
"% runs:\n".postf(char);
3.do { [" ", i, char].join($ ).postln; 0.1.wait };
}.play;
};
s.doWhenBooted({ "DDD".postln; });
s.doWhenBooted({ "EEE".postln; });
s.doWhenBooted({ "FFF".postln; });
)
s.waitForBoot({ "waitForBoot runs...".postln });
X runs:
0 X
Y runs:
1 Y
Z runs:
2 Z
waitForBoot runs...
AAA
BBB
CCC
DDD
EEE
FFF
0 X
1 Y
2 Z
0 X
1 Y
2 Z |
dear @brianlheim, thanks for pointing out conditions, |
I'm afraid I'm in the middle of an apartment move, not much time for careful review. I'm glad to see that you ran with it -- eager to take a closer look, but overwhelmed at the moment. |
@jamshark70 - no hurry, and still too early for a detailed review!
|
Looks like a very good direction to move towards! Here a first error report:
when running s.quit;
Routine {
var name = "Routine A";
"% waiting for booting to start ...\n".postf(name);
s.process.startedBootingCondition.wait;
"% boot started, waiting for hasBooted ...\n".postf(name);
s.process.hasBootedCondition.wait;
"% booted, waiting for server ready ...\n".postf(name);
s.process.isReadyCondition.wait;
"% READY! now waiting for server quit ...\n".postf(name);
s.process.hasQuitCondition.wait;
"% ends, quit done.\n".postf(name);
}.play;
s.boot; |
@telephon - thanks for testing! I guess you ran did you run |
Quick initial report: wslib will need an update for this.
Well, extension authors should be careful about referencing object internals anyway (program to the interface, not the implementation...). |
I'm testing this branch now. One thing (not sure if it's already reported) -- if the server process dies, nobody notices.
|
I just got this:
But
So there is some weird possible race condition where the server boots successfully, but ServerProcess thinks it failed. The failure was basically immediate. I had recompiled the class library, then ran a I have to prepare some SC things for class, no time for this now, I have to go back to vanilla 3.9 for the moment. Otherwise I would investigate, but... this is weird. |
Milestoning this as 3.10; it's not really appropriate for a patch release. |
@adcxyz where are we with all this? Is there a small first step to be made for 3.10, or better a larger one for 3.11 ? |
Since so many details in Server.sc have changed, it needs a rewrite based on the current develop branch; the old version worked pretty well, and can be used as a model for the structure. Useful small steps would be moving ServerOptions and ServerShmInterface to separate files... |
In the discussion on #3286 and complicated PR #3299,
@jamshark70 had the insight that ServerStatusWatcher should actually be responsible for handling the entire admin for the server process: booting, watching status, and quitting.
I have started to explore this idea in a branch:
https://github.com/adcxyz/supercollider/tree/server_ServerProcess
This is a massive refactoring of Server, ServerStatusWatcher based on #3299,
and looks promising so far - not at all finished yet, so not a PR yet.
Now the ServerProcess class replaces ServerStatusWatcher
and handles boot, quit, and running status of a server process.
The status code is copied and adapted from ServerStatusWatcher,
boot and quit-related methods are copied and refactored from Server.
The Server class now focuses only on 'content': allocation, synths, controls, etc.
*** Disclaimers :
much of the earlier code interface, but this is not complete at all.
*** Pluses:
all boot steps are in a single boot routine
logic is a lot clearer and easier to read
uses conditions to speed up booting and trigger waiting tasks
process state is always one of
#[\isOff, \isBooting, \isSettingUp, \isReady, \isQuitting];
other state flags are kept for internal use, such as hasBooted, unresponsive
ca. 40% faster booting on macOS (measured ca. 0.65 sec vs 1.15 sec avg)
Opinions welcome!
For all current doc and tests, see
ServerProcess.help
*** TODO: ***
The text was updated successfully, but these errors were encountered: