git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit e210ee60ee3b72696f7da750046fb41d41785da5

fixed bugs

wanderer committed on 12/12/2017, 10:22:23 PM
Parent: e47dbb585f72b65914431ec10f554e43226dc121

Files changed

actor.jschanged
index.jschanged
scheduler.jschanged
tests/index.jschanged
actor.jsView
@@ -2,9 +2,8 @@
22 const Pipe = require('buffer-pipe')
33 const Cap = require('primea-capability')
44 const Message = require('primea-message')
55 const leb128 = require('leb128').unsigned
6-const LockMap = require('lockmap')
76 const Inbox = require('./inbox.js')
87
98 module.exports = class Actor {
109 /**
@@ -26,9 +25,8 @@
2625 })
2726
2827 this.ticks = 0
2928 this.running = false
30- this._sending = new LockMap()
3129 }
3230
3331 /**
3432 * Mints a new capabilitly with a given tag
@@ -54,13 +52,11 @@
5452 * @param {object} message
5553 * @returns {Promise}
5654 */
5755 create (message) {
58- // start loop before running intializtion message so the the container state
59- // will be "running" incase the actor recievse a message will running
60- // creation code
61- this._startMessageLoop()
62- return this.runMessage(message, 'onCreation')
56+ return this.runMessage(message, 'onCreation').then(() => {
57+ this._startMessageLoop()
58+ })
6359 }
6460
6561 // waits for the next message
6662 async _startMessageLoop () {
@@ -74,9 +70,8 @@
7470 // run the next message
7571 await this.runMessage(message)
7672 // wait for state ops to finish
7773 await this.state.done()
78- await Promise.all([...this._sending.values()])
7974 }
8075
8176 this.running = false
8277 this.container.onIdle()
@@ -180,12 +175,11 @@
180175 * @param {Object} portRef - the port
181176 * @param {Message} message - the message
182177 */
183178 send (cap, message) {
184- const resolve = this._sending.lock(cap)
185179 message._fromTicks = this.ticks
186180 message._fromId = this.id
187181 message.tag = cap.tag
188182
189- return this.hypervisor.send(cap, message).then(() => resolve(cap))
183+ return this.hypervisor.send(cap, message)
190184 }
191185 }
index.jsView
@@ -80,9 +80,9 @@
8080 // create the container instance
8181 const instance = await this._loadActor(idHash)
8282
8383 // send the intialization message
84- await instance.create(message)
84+ instance.create(message)
8585 return instance.mintCap()
8686 }
8787
8888 // get a hash from a POJO
scheduler.jsView
@@ -103,14 +103,9 @@
103103 return ticks
104104 }
105105
106106 // checks outstanding waits to see if they can be resolved
107- async _checkWaits () {
108- if (this._checkingWaits) {
109- return
110- }
111- this._checkingWaits = true
112-
107+ _checkWaits () {
113108 // if there are no instances, clear any remaining waits
114109 if (!this.instances.size) {
115110 this._waits.forEach(wait => wait.resolve())
116111 this._waits = []
tests/index.jsView
@@ -299,9 +299,9 @@
299299
300300 class testVMContainerB extends BaseContainer {
301301 onCreation (m) {
302302 const cap = m.caps[0]
303- return this.actor.send(cap, new Message({data: 'test'}))
303+ this.actor.send(cap, new Message({data: 'test'}))
304304 }
305305
306306 static get typeId () {
307307 return 8

Built with git-ssb-web