git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit c779344f6653a07ed5e2695bca74c9cbd0c66a19

updated docs

Signed-off-by: wanderer <mjbecze@gmail.com>
wanderer committed on 1/23/2018, 8:29:36 PM
Parent: 5a33099559b3af6b0c5c0e444a8d537471853b77

Files changed

actor.jschanged
docs/inbox.mddeleted
package-lock.jsonchanged
package.jsonchanged
scheduler.jschanged
actor.jsView
@@ -14,9 +14,8 @@
1414 constructor (opts) {
1515 Object.assign(this, opts)
1616
1717 this.inbox = []
18-
1918 this.ticks = 0
2019 this.running = false
2120 }
2221
docs/inbox.mdView
@@ -1,42 +1,0 @@
1-<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
2-
3-### Table of Contents
4-
5-- [constructor](#constructor)
6-- [queue](#queue)
7-- [nextMessage](#nextmessage)
8-
9-## constructor
10-
11-[inbox.js:24-31](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/inbox.js#L24-L31 "Source code on GitHub")
12-
13-The inbox manages and sorts incoming messages and provides functions
14-to wait on messages
15-
16-**Parameters**
17-
18-- `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
19- - `opts.state` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
20- - `opts.hypervisor` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
21-
22-## queue
23-
24-[inbox.js:41-51](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/inbox.js#L41-L51 "Source code on GitHub")
25-
26-queues a message
27-
28-**Parameters**
29-
30-- `message` **Message**
31-
32-## nextMessage
33-
34-[inbox.js:58-91](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/inbox.js#L58-L91 "Source code on GitHub")
35-
36-Waits for the the next message if any
37-
38-**Parameters**
39-
40-- `timeout` **Integer**
41-
42-Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
package-lock.jsonView
The diff is too large to show. Use a local git client to view these changes.
Old file size: 341063 bytes
New file size: 341262 bytes
package.jsonView
@@ -9,10 +9,8 @@
99 "build:docs": "npm run build:docs:hypervisor && npm run build:docs:actor && npm run build:docs:scheduler && npm run build:docs:capsStore && npm run build:docs:inbox",
1010 "build:docs:hypervisor": "documentation build ./index.js --github --shallow --sort-order source -f md > ./docs/hypervisor.md",
1111 "build:docs:actor": "documentation build ./actor.js --github --shallow --sort-order source -f md > ./docs/actor.md",
1212 "build:docs:capsStore": "documentation build ./capsStore.js --github --shallow --sort-order source -f md > ./docs/capsStore.md",
13- "build:docs:scheduler": "documentation build ./scheduler.js --github --shallow --sort-order source -f md > ./docs/scheduler.md",
14- "build:docs:inbox": "documentation build ./inbox.js --github --shallow --sort-order source -f md > ./docs/inbox.md",
1513 "test": "node ./tests/index.js"
1614 },
1715 "repository": {
1816 "type": "git",
@@ -30,8 +28,9 @@
3028 "author": "mjbecze <mjbecze@gmail.com>",
3129 "contributors": "Alex Beregszaszi <alex@rtfs.hu>",
3230 "license": "MPL-2.0",
3331 "dependencies": {
32+ "binary-search": "^1.3.2",
3433 "binary-search-insert": "^1.0.3",
3534 "buffer-pipe": "0.0.2",
3635 "events": "^1.1.1",
3736 "leb128": "0.0.4",
scheduler.jsView
@@ -1,7 +1,6 @@
11 const EventEmitter = require('events')
22 const binarySearchInsert = require('binary-search-insert')
3-// const bs = require('binary-search')
43
54 // decides which message to go first
65 function comparator (messageA, messageB) {
76 // order by number of ticks if messages have different number of ticks
@@ -22,31 +21,25 @@
2221 this.hypervisor = hypervisor
2322 this._messages = []
2423 this._times = []
2524 this.actors = new Map()
26- this._state = 'idle'
25+ this._running = false
2726 }
2827
2928 queue (messages) {
3029 messages.forEach(msg => binarySearchInsert(this._messages, comparator, msg))
31- if (this._state === 'idle') {
32- this._state = 'running'
30+ if (!this._running) {
31+ this._running = true
3332 this._messageLoop()
3433 }
3534 }
3635
3736 async _messageLoop () {
38- let waits = []
3937 while (this._messages.length) {
4038 const message = this._messages.shift()
41- waits.push(this._processMessage(message))
42- const oldestMessage = this._messages[0]
43- if (!oldestMessage || oldestMessage._fromTicks !== message._fromTicks) {
44- await Promise.all(waits)
45- waits = []
46- }
39+ await this._processMessage(message)
4740 }
48- this._state = 'idle'
41+ this._running = false
4942 const promises = []
5043 this.actors.forEach(actor => promises.push(actor.shutdown()))
5144 await Promise.all(promises)
5245 this.actors.clear()
@@ -54,18 +47,8 @@
5447 }
5548
5649 // enable for concurrency
5750 update (oldTicks, ticks) {
58- // const index = bs(this._times, oldTicks, (a, b) => a - b)
59- // this._times.splice(index, 1)
60- // binarySearchInsert(this._times, (a, b) => { return a - b }, ticks)
61- // let oldestMessage = this._messages[0]
62- // const oldestTime = this._times[0]
63- // while (oldestMessage && oldestMessage._fromTicks < oldestTime) {
64- // const message = this._messages.shift()
65- // this._processMessage(message)
66- // oldestMessage = this._messages[0]
67- // }
6851 }
6952
7053 async _processMessage (message) {
7154 const to = message.funcRef.destId.toString('hex')

Built with git-ssb-web