Yeah, decided to move these out of the Question thread.
Proof of concept – change interpretPrintCmdLine like so:
interpretPrintCmdLine {
var res, func, code = cmdLine, doc, ideClass = \ScIDE.asClass;
preProcessor !? { cmdLine = preProcessor.value(cmdLine, this) };
func = this.compile(cmdLine);
if (ideClass.notNil) {
thisProcess.nowExecutingPath = ideClass.currentPath
} {
if(\Document.asClass.notNil and: {(doc = Document.current).tryPerform(\dataptr).notNil}) {
thisProcess.nowExecutingPath = doc.tryPerform(\path);
}
};
{
res = func.value;
thisProcess.nowExecutingPath = nil;
codeDump.value(code, res, func, this);
("-> " ++ res).postln;
}.fork(AppClock);
}
AFAICS the only potentially negative impact is that, without this change, code that is executed directly reports thisThread = “a Routine” instead of “a Thread” – probably nobody is dependent on that…?
Then, fold CondVar stuff into VSTPluginController:open (note, just using VSTPluginController as an example, since that’s what the original thread was about) –
open { arg path, editor=true, verbose=false, action, multiThreading=false, mode, timeout = 5;
var intMode = 0;
var condVar = CondVar.new;
... snip ...
loading = false;
deferred = multiThreading || (mode.asSymbol != \auto) || info.bridged;
this.changed(\open, path, loaded);
action.value(this, loaded);
// report latency (if loaded)
latency !? { latencyChanged.value(latency); }
condVar.signalOne;
}, '/vst_open').oneShot;
// don't set 'info' property yet; use original path!
this.sendMsg('/open', path.asString.standardizePath,
editor.asInteger, multiThreading.asInteger, intMode);
} {
"couldn't open '%'".format(path).error;
// just notify failure, but keep old plugin (if present)
loading = false;
action.value(this, false);
condVar.signalOne;
};
... snip ...
Then:
(
SynthDef(\vst, { |out = 0|
Out.ar(out, VSTPlugin.ar(numOut: 2));
}).add;
)
// no Routine, no fork!
(
a = Synth(\vst);
c = VSTPluginController(a);
c.open("sfizz.vst3"/*, mode: \sandbox*/);
c.isOpen.debug("plugin loaded");
)
read cache file /home/dlm/.local/share/vstplugin/sc/cache_amd64.ini
wine-6.0.3 (Ubuntu 6.0.3~repack-1)
wine-6.0.3 (Ubuntu 6.0.3~repack-1)
plugin loaded: true
Thread-unblocking is properly deferred.
Buffer reading would benefit from a true Deferred
though, because we don’t want to block each individual read.
hjh