git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 5a462dae8e421e6271dd15faf3802048e0f23596

remove extra compater function

wanderer committed on 11/21/2017, 9:38:45 PM
Parent: 622b5589b3a43d425004534b7b44c376d3e740c7

Files changed

inbox.jschanged
scheduler.jschanged
inbox.jsView
@@ -1,7 +1,18 @@
11 const binarySearchInsert = require('binary-search-insert')
22 const Buffer = require('safe-buffer').Buffer
33
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+
415 module.exports = class Inbox {
516 /**
617 * The inbox manages and sorts incoming messages and provides functions
718 * to wait on messages
@@ -131,15 +142,4 @@
131142 return false
132143 }
133144 }
134145 }
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.jsView
@@ -1,8 +1,12 @@
11 const binarySearchInsert = require('binary-search-insert')
22 const SortedMap = require('sortedmap')
33 const LockMap = require('lockmap')
44
5+function comparator (a, b) {
6+ return a.ticks - b.ticks
7+}
8+
59 module.exports = class Scheduler {
610 /**
711 * The Scheduler manages the run cycle of Actors and figures out which
812 * order they should run in
@@ -10,13 +14,10 @@
1014 constructor () {
1115 this._waits = []
1216 this._running = new Set()
1317 this._loadingInstances = new LockMap()
18+ this._checkingWaits = false
1419 this.instances = new SortedMap(comparator)
15-
16- function comparator (a, b) {
17- return a.ticks - b.ticks
18- }
1920 }
2021
2122 /**
2223 * locks the scheduler from clearing waits untill the lock is resolved
@@ -78,12 +79,8 @@
7879 id: id
7980 })
8081 this._checkWaits()
8182 })
82-
83- function comparator (a, b) {
84- return a.ticks - b.ticks
85- }
8683 }
8784
8885 /**
8986 * returns the oldest container's ticks

Built with git-ssb-web