kopia lustrzana https://github.com/backface/turtlestitch
commit
1da3ae32aa
|
@ -591,6 +591,11 @@ SpriteMorph.prototype.initBlocks = function () {
|
|||
category: 'control',
|
||||
spec: 'stop all %stop'
|
||||
},
|
||||
doStopOthers: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
spec: 'stop other scripts in sprite'
|
||||
},
|
||||
doRun: {
|
||||
type: 'command',
|
||||
category: 'control',
|
||||
|
@ -1649,6 +1654,7 @@ SpriteMorph.prototype.blockTemplates = function (category) {
|
|||
blocks.push(block('doStopBlock'));
|
||||
blocks.push(block('doStop'));
|
||||
blocks.push(block('doStopAll'));
|
||||
blocks.push(block('doStopOthers'));
|
||||
blocks.push('-');
|
||||
blocks.push(block('doRun'));
|
||||
blocks.push(block('fork'));
|
||||
|
|
21
threads.js
21
threads.js
|
@ -168,6 +168,17 @@ ThreadManager.prototype.stopAllForReceiver = function (rcvr) {
|
|||
});
|
||||
};
|
||||
|
||||
ThreadManager.prototype.stopAllForReceiverExcept = function (rcvr, excpt) {
|
||||
this.processes.forEach(function (proc) {
|
||||
if (proc.homeContext.receiver === rcvr && proc != excpt) {
|
||||
proc.stop();
|
||||
if (rcvr.isClone) {
|
||||
proc.isDead = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ThreadManager.prototype.stopProcess = function (block) {
|
||||
var active = this.findProcess(block);
|
||||
if (active) {
|
||||
|
@ -1368,6 +1379,16 @@ Process.prototype.doStopAll = function () {
|
|||
}
|
||||
};
|
||||
|
||||
Process.prototype.doStopOthers = function () {
|
||||
var stage, ide;
|
||||
if (this.homeContext.receiver) {
|
||||
stage = this.homeContext.receiver.parentThatIsA(StageMorph);
|
||||
if (stage) {
|
||||
stage.threads.stopAllForReceiverExcept(this.homeContext.receiver, this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Process.prototype.doWarp = function (body) {
|
||||
// execute my contents block atomically (more or less)
|
||||
var outer = this.context.outerContext, // for tail call elimination
|
||||
|
|
Ładowanie…
Reference in New Issue