highlevelidioms.whileblocking.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of BPjs Show documentation
Show all versions of BPjs Show documentation
Provides runtime and analysis for behavioral programs written in
JavaScript. It can run stand-alone (from the commmandline) or be
embedded in larger JVM-based systems.
The newest version!
/* global bsync, blocking */
var _bsync = bsync;
new Object {
blocking: new EventStack(),
whileBlocking: function(blocked, f) {
try {
blocking.push(blocked);
f();
return blocking.pop();
} catch (thrownEvent) {
blocking.pop();
throw thrownEvent;
}
},
bsync: function(requested, wait, blocked) {
var e;
if (!this.blocking.isEmpty()) {
var eset = new EventSet([blocked, this.blocking]);
e = _bsync(requested, wait, eset);
} else {
e = _bsync(requested, wait, blocked);
}
return e;
}
};