Singleton fudgery
This commit is contained in:
parent
d04d4f0095
commit
2223f29ad2
|
@ -23,6 +23,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
"immutable": "^3.8.2",
|
"immutable": "^3.8.2",
|
||||||
"preserves": "0.0.9"
|
"preserves": "0.0.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,22 +37,38 @@ const PRIORITY = Object.freeze({
|
||||||
_count: 6
|
_count: 6
|
||||||
});
|
});
|
||||||
|
|
||||||
function Dataspace(bootProc) {
|
// Singleton hackery.
|
||||||
this.nextId = 0;
|
const Dataspace = (function () {
|
||||||
this.index = new Skeleton.Index();
|
const SYNDICATE = Symbol.for('@syndicate-lang/core');
|
||||||
this.dataflow = new Dataflow.Graph();
|
const version = require('../package.json').version;
|
||||||
this.runnable = Immutable.List();
|
if (!(SYNDICATE in global)) {
|
||||||
this.pendingActions = Immutable.List([
|
global[SYNDICATE] = {
|
||||||
new ActionGroup(null, Immutable.List([new Spawn(null, bootProc, Immutable.Set())]))]);
|
version: version,
|
||||||
this.activatedModules = Immutable.Set();
|
Dataspace: function (bootProc) {
|
||||||
this.actors = Immutable.Map();
|
this.nextId = 0;
|
||||||
}
|
this.index = new Skeleton.Index();
|
||||||
|
this.dataflow = new Dataflow.Graph();
|
||||||
|
this.runnable = Immutable.List();
|
||||||
|
this.pendingActions = Immutable.List([
|
||||||
|
new ActionGroup(null, Immutable.List([new Spawn(null, bootProc, Immutable.Set())]))]);
|
||||||
|
this.activatedModules = Immutable.Set();
|
||||||
|
this.actors = Immutable.Map();
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const g = global[SYNDICATE];
|
||||||
|
if (g.version !== version) {
|
||||||
|
console.warn('Potentially incompatible versions of @syndicate-lang/core loaded:',
|
||||||
|
version, g.version);
|
||||||
|
}
|
||||||
|
return g.Dataspace;
|
||||||
|
})();
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
Dataspace._currentFacet = null;
|
Dataspace._currentFacet = null;
|
||||||
Dataspace._inScript = true;
|
Dataspace._inScript = true;
|
||||||
|
|
||||||
Dataspace.BootSteps = Symbol('SyndicateBootSteps');
|
Dataspace.BootSteps = Symbol.for('SyndicateBootSteps');
|
||||||
|
|
||||||
Dataspace.currentFacet = function () {
|
Dataspace.currentFacet = function () {
|
||||||
return Dataspace._currentFacet;
|
return Dataspace._currentFacet;
|
||||||
|
|
Loading…
Reference in New Issue