|
|
@ -80,9 +80,14 @@ Function.prototype.toString = function () { |
|
|
|
const MAX_ENVS = 10; |
|
|
|
const MAX_ENVS = 10; |
|
|
|
let drpyEnvS = globalMap0.getVar('drpyEnvS',{}); |
|
|
|
let drpyEnvS = globalMap0.getVar('drpyEnvS',{}); |
|
|
|
let nextEnvId = 0; |
|
|
|
let nextEnvId = 0; |
|
|
|
|
|
|
|
let lock = false; |
|
|
|
|
|
|
|
|
|
|
|
function createOrGetEnvironment(id, ext) { |
|
|
|
function createOrGetEnvironment(id, ext) { |
|
|
|
|
|
|
|
while (lock) { |
|
|
|
|
|
|
|
// 等待锁释放
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
lock = true; |
|
|
|
|
|
|
|
try { |
|
|
|
if (id === undefined) { |
|
|
|
if (id === undefined) { |
|
|
|
id = nextEnvId++; |
|
|
|
id = nextEnvId++; |
|
|
|
} |
|
|
|
} |
|
|
@ -98,7 +103,6 @@ function createOrGetEnvironment(id, ext) { |
|
|
|
const oldestId = Object.keys(drpyEnvS).sort((a, b) => a - b)[0]; |
|
|
|
const oldestId = Object.keys(drpyEnvS).sort((a, b) => a - b)[0]; |
|
|
|
log(oldestId+'>drpy删除'); |
|
|
|
log(oldestId+'>drpy删除'); |
|
|
|
delete drpyEnvS[oldestId]; |
|
|
|
delete drpyEnvS[oldestId]; |
|
|
|
//globalMap0.putVar('drpyEnvS', drpyEnvS);
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
drpyEnvS[id] = (function() { |
|
|
|
drpyEnvS[id] = (function() { |
|
|
@ -106,8 +110,11 @@ function createOrGetEnvironment(id, ext) { |
|
|
|
return drpy2.DRPY(); |
|
|
|
return drpy2.DRPY(); |
|
|
|
})(); |
|
|
|
})(); |
|
|
|
drpyEnvS[id].init(ext); |
|
|
|
drpyEnvS[id].init(ext); |
|
|
|
//globalMap0.putVar('drpyEnvS', drpyEnvS);
|
|
|
|
globalMap0.putVar('drpyEnvS', drpyEnvS); |
|
|
|
return drpyEnvS[id]; |
|
|
|
return drpyEnvS[id]; |
|
|
|
|
|
|
|
} finally { |
|
|
|
|
|
|
|
lock = false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
log(Object.keys(drpyEnvS).length); |
|
|
|
log(Object.keys(drpyEnvS).length); |
|
|
|
$.exports = { |
|
|
|
$.exports = { |
|
|
|