Skip to content

Commit

Permalink
remove extra compater function
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderer committed Nov 21, 2017
1 parent 622b558 commit 5a462da
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
22 changes: 11 additions & 11 deletions inbox.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
const binarySearchInsert = require('binary-search-insert')
const Buffer = require('safe-buffer').Buffer

// decides which message to go first
function messageArbiter (messageA, messageB) {
// order by number of ticks if messages have different number of ticks
if (messageA._fromTicks !== messageB._fromTicks) {
return messageA._fromTicks > messageB._fromTicks
} else {
// sender id
return Buffer.compare(messageA._fromId, messageB._fromId)
}
}

module.exports = class Inbox {
/**
* The inbox manages and sorts incoming messages and provides functions
Expand Down Expand Up @@ -132,14 +143,3 @@ module.exports = class Inbox {
}
}
}

// decides which message to go first
function messageArbiter (messageA, messageB) {
// order by number of ticks if messages have different number of ticks
if (messageA._fromTicks !== messageB._fromTicks) {
return messageA._fromTicks > messageB._fromTicks
} else {
// sender id
return Buffer.compare(messageA._fromId, messageB._fromId)
}
}
13 changes: 5 additions & 8 deletions scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const binarySearchInsert = require('binary-search-insert')
const SortedMap = require('sortedmap')
const LockMap = require('lockmap')

function comparator (a, b) {
return a.ticks - b.ticks
}

module.exports = class Scheduler {
/**
* The Scheduler manages the run cycle of Actors and figures out which
Expand All @@ -11,11 +15,8 @@ module.exports = class Scheduler {
this._waits = []
this._running = new Set()
this._loadingInstances = new LockMap()
this._checkingWaits = false
this.instances = new SortedMap(comparator)

function comparator (a, b) {
return a.ticks - b.ticks
}
}

/**
Expand Down Expand Up @@ -79,10 +80,6 @@ module.exports = class Scheduler {
})
this._checkWaits()
})

function comparator (a, b) {
return a.ticks - b.ticks
}
}

/**
Expand Down

0 comments on commit 5a462da

Please sign in to comment.