Still whacking away at the singleton issue
This commit is contained in:
parent
fd85494672
commit
782d97a3ba
|
@ -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.11"
|
"preserves": "0.0.12"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,11 @@
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
if (require('preserves/src/singletonmodule.js')('syndicate-lang.org/syndicate-js',
|
||||||
|
require('../package.json').version,
|
||||||
|
'dataspace.js',
|
||||||
|
module)) return;
|
||||||
|
|
||||||
const Immutable = require("immutable");
|
const Immutable = require("immutable");
|
||||||
const Preserves = require("preserves");
|
const Preserves = require("preserves");
|
||||||
// const debug = require("debug")("syndicate/core:dataspace");
|
// const debug = require("debug")("syndicate/core:dataspace");
|
||||||
|
@ -37,39 +42,6 @@ const PRIORITY = Object.freeze({
|
||||||
_count: 6
|
_count: 6
|
||||||
});
|
});
|
||||||
|
|
||||||
// Singleton hackery.
|
|
||||||
const Dataspace = (function () {
|
|
||||||
const SYNDICATE = Symbol.for('@syndicate-lang/core');
|
|
||||||
const version = require('../package.json').version;
|
|
||||||
if (!(SYNDICATE in global)) {
|
|
||||||
function Dataspace(bootProc) {
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parameters
|
|
||||||
Dataspace._currentFacet = null;
|
|
||||||
Dataspace._inScript = true;
|
|
||||||
|
|
||||||
global[SYNDICATE] = {
|
|
||||||
version: version,
|
|
||||||
Dataspace: Dataspace,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const g = global[SYNDICATE];
|
|
||||||
if (g.version !== version) {
|
|
||||||
console.warn('Potentially incompatible versions of @syndicate-lang/core loaded:',
|
|
||||||
version, g.version);
|
|
||||||
}
|
|
||||||
return g.Dataspace;
|
|
||||||
})();
|
|
||||||
|
|
||||||
Dataspace.BootSteps = Symbol.for('SyndicateBootSteps');
|
Dataspace.BootSteps = Symbol.for('SyndicateBootSteps');
|
||||||
|
|
||||||
Dataspace.currentFacet = function () {
|
Dataspace.currentFacet = function () {
|
||||||
|
|
Loading…
Reference in New Issue