Commit 5a462dae8e421e6271dd15faf3802048e0f23596
remove extra compater function
wanderer committed on 11/21/2017, 9:38:45 PMParent: 622b5589b3a43d425004534b7b44c376d3e740c7
Files changed
inbox.js | changed |
scheduler.js | changed |
inbox.js | ||
---|---|---|
@@ -1,7 +1,18 @@ | ||
1 | 1 | const binarySearchInsert = require('binary-search-insert') |
2 | 2 | const Buffer = require('safe-buffer').Buffer |
3 | 3 | |
4 | +// decides which message to go first | |
5 | +function messageArbiter (messageA, messageB) { | |
6 | + // order by number of ticks if messages have different number of ticks | |
7 | + if (messageA._fromTicks !== messageB._fromTicks) { | |
8 | + return messageA._fromTicks > messageB._fromTicks | |
9 | + } else { | |
10 | + // sender id | |
11 | + return Buffer.compare(messageA._fromId, messageB._fromId) | |
12 | + } | |
13 | +} | |
14 | + | |
4 | 15 | module.exports = class Inbox { |
5 | 16 | /** |
6 | 17 | * The inbox manages and sorts incoming messages and provides functions |
7 | 18 | * to wait on messages |
@@ -131,15 +142,4 @@ | ||
131 | 142 | return false |
132 | 143 | } |
133 | 144 | } |
134 | 145 | } |
135 | - | |
136 | -// decides which message to go first | |
137 | -function messageArbiter (messageA, messageB) { | |
138 | - // order by number of ticks if messages have different number of ticks | |
139 | - if (messageA._fromTicks !== messageB._fromTicks) { | |
140 | - return messageA._fromTicks > messageB._fromTicks | |
141 | - } else { | |
142 | - // sender id | |
143 | - return Buffer.compare(messageA._fromId, messageB._fromId) | |
144 | - } | |
145 | -} |
scheduler.js | ||
---|---|---|
@@ -1,8 +1,12 @@ | ||
1 | 1 | const binarySearchInsert = require('binary-search-insert') |
2 | 2 | const SortedMap = require('sortedmap') |
3 | 3 | const LockMap = require('lockmap') |
4 | 4 | |
5 | +function comparator (a, b) { | |
6 | + return a.ticks - b.ticks | |
7 | +} | |
8 | + | |
5 | 9 | module.exports = class Scheduler { |
6 | 10 | /** |
7 | 11 | * The Scheduler manages the run cycle of Actors and figures out which |
8 | 12 | * order they should run in |
@@ -10,13 +14,10 @@ | ||
10 | 14 | constructor () { |
11 | 15 | this._waits = [] |
12 | 16 | this._running = new Set() |
13 | 17 | this._loadingInstances = new LockMap() |
18 | + this._checkingWaits = false | |
14 | 19 | this.instances = new SortedMap(comparator) |
15 | - | |
16 | - function comparator (a, b) { | |
17 | - return a.ticks - b.ticks | |
18 | - } | |
19 | 20 | } |
20 | 21 | |
21 | 22 | /** |
22 | 23 | * locks the scheduler from clearing waits untill the lock is resolved |
@@ -78,12 +79,8 @@ | ||
78 | 79 | id: id |
79 | 80 | }) |
80 | 81 | this._checkWaits() |
81 | 82 | }) |
82 | - | |
83 | - function comparator (a, b) { | |
84 | - return a.ticks - b.ticks | |
85 | - } | |
86 | 83 | } |
87 | 84 | |
88 | 85 | /** |
89 | 86 | * returns the oldest container's ticks |
Built with git-ssb-web