From 1c876fe110abc24ab3a7957c9e8c2a55be943342 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Tue, 22 Mar 2016 10:16:49 -0700 Subject: [PATCH] update --- examples/libraries/virtualBaton.js | 48 +++++++++---------- .../batonSoundTestEntityScript.js | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/libraries/virtualBaton.js b/examples/libraries/virtualBaton.js index 5a6e577bc1..d6c73db5dd 100644 --- a/examples/libraries/virtualBaton.js +++ b/examples/libraries/virtualBaton.js @@ -145,32 +145,32 @@ function virtualBatonf(options) { // It would be great if we had a way to know how many subscribers our channel has. Failing that... var nNack = 0, previousNSubscribers = 0, lastGathering = 0, thisTimeout = electionTimeout; function nSubscribers() { // Answer the number of subscribers. - // // To find nQuorum, we need to know how many scripts are being run using this batonName, which isn't - // // the same as the number of clients! - // // - // // If we overestimate by too much, we may fail to reach consensus, which triggers a new - // // election proposal, so we take the number of acceptors to be the max(nPromises, nAccepted) - // // + nNack reported in the previous round. - // // - // // If we understimate by too much, there can be different pockets on the Internet that each - // // believe they have agreement on different holders of the baton, which is precisely what - // // the virtualBaton is supposed to avoid. Therefore we need to allow 'nack' to gather stragglers. + // To find nQuorum, we need to know how many scripts are being run using this batonName, which isn't + // the same as the number of clients! + // + // If we overestimate by too much, we may fail to reach consensus, which triggers a new + // election proposal, so we take the number of acceptors to be the max(nPromises, nAccepted) + // + nNack reported in the previous round. + // + // If we understimate by too much, there can be different pockets on the Internet that each + // believe they have agreement on different holders of the baton, which is precisely what + // the virtualBaton is supposed to avoid. Therefore we need to allow 'nack' to gather stragglers. - // var now = Date.now(), elapsed = now - lastGathering; - // if (elapsed >= thisTimeout) { - // previousNSubscribers = Math.max(nPromises, nAccepted) + nNack; - // lastGathering = now; - // } // ...otherwise we use the previous value unchanged. + var now = Date.now(), elapsed = now - lastGathering; + if (elapsed >= thisTimeout) { + previousNSubscribers = Math.max(nPromises, nAccepted) + nNack; + lastGathering = now; + } // ...otherwise we use the previous value unchanged. - // // On startup, we do one proposal that we cannot possibly close, so that we'll - // // lock things up for the full electionTimeout to gather responses. - // if (!previousNSubscribers) { - // var LARGE_INTEGER = Number.MAX_SAFE_INTEGER || (-1 >>> 1); // QT doesn't define the ECMA constant. Max int will do for our purposes. - // previousNSubscribers = LARGE_INTEGER; - // } - // return previousNSubscribers; - print("EBL NUMBER SUBSCRIBERS ", AvatarList.getAvatarIdentifiers().length); - return AvatarList.getAvatarIdentifiers().length; + // On startup, we do one proposal that we cannot possibly close, so that we'll + // lock things up for the full electionTimeout to gather responses. + if (!previousNSubscribers) { + var LARGE_INTEGER = Number.MAX_SAFE_INTEGER || (-1 >>> 1); // QT doesn't define the ECMA constant. Max int will do for our purposes. + previousNSubscribers = LARGE_INTEGER; + } + return previousNSubscribers; + // print("EBL NUMBER SUBSCRIBERS ", AvatarList.getAvatarIdentifiers().length); + // return AvatarList.getAvatarIdentifiers().length; } // MAIN ALGORITHM diff --git a/examples/tests/batonSoundEntityTest/batonSoundTestEntityScript.js b/examples/tests/batonSoundEntityTest/batonSoundTestEntityScript.js index e42c855f10..4cbe98a2ce 100644 --- a/examples/tests/batonSoundEntityTest/batonSoundTestEntityScript.js +++ b/examples/tests/batonSoundEntityTest/batonSoundTestEntityScript.js @@ -76,7 +76,7 @@ unload: function() { print("EBL UNLOAD"); - baton.release(); + baton.release(function(){}); baton.unload(); Entities.deleteEntity(_this.batonDebugModel); if (_this.soundIntervalConnected === true) {