Commit e210ee60ee3b72696f7da750046fb41d41785da5
fixed bugs
wanderer committed on 12/12/2017, 10:22:23 PMParent: e47dbb585f72b65914431ec10f554e43226dc121
Files changed
actor.js | changed |
index.js | changed |
scheduler.js | changed |
tests/index.js | changed |
actor.js | ||
---|---|---|
@@ -2,9 +2,8 @@ | ||
2 | 2 | const Pipe = require('buffer-pipe') |
3 | 3 | const Cap = require('primea-capability') |
4 | 4 | const Message = require('primea-message') |
5 | 5 | const leb128 = require('leb128').unsigned |
6 | -const LockMap = require('lockmap') | |
7 | 6 | const Inbox = require('./inbox.js') |
8 | 7 | |
9 | 8 | module.exports = class Actor { |
10 | 9 | /** |
@@ -26,9 +25,8 @@ | ||
26 | 25 | }) |
27 | 26 | |
28 | 27 | this.ticks = 0 |
29 | 28 | this.running = false |
30 | - this._sending = new LockMap() | |
31 | 29 | } |
32 | 30 | |
33 | 31 | /** |
34 | 32 | * Mints a new capabilitly with a given tag |
@@ -54,13 +52,11 @@ | ||
54 | 52 | * @param {object} message |
55 | 53 | * @returns {Promise} |
56 | 54 | */ |
57 | 55 | 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 | + }) | |
63 | 59 | } |
64 | 60 | |
65 | 61 | // waits for the next message |
66 | 62 | async _startMessageLoop () { |
@@ -74,9 +70,8 @@ | ||
74 | 70 | // run the next message |
75 | 71 | await this.runMessage(message) |
76 | 72 | // wait for state ops to finish |
77 | 73 | await this.state.done() |
78 | - await Promise.all([...this._sending.values()]) | |
79 | 74 | } |
80 | 75 | |
81 | 76 | this.running = false |
82 | 77 | this.container.onIdle() |
@@ -180,12 +175,11 @@ | ||
180 | 175 | * @param {Object} portRef - the port |
181 | 176 | * @param {Message} message - the message |
182 | 177 | */ |
183 | 178 | send (cap, message) { |
184 | - const resolve = this._sending.lock(cap) | |
185 | 179 | message._fromTicks = this.ticks |
186 | 180 | message._fromId = this.id |
187 | 181 | message.tag = cap.tag |
188 | 182 | |
189 | - return this.hypervisor.send(cap, message).then(() => resolve(cap)) | |
183 | + return this.hypervisor.send(cap, message) | |
190 | 184 | } |
191 | 185 | } |
index.js | ||
---|---|---|
@@ -80,9 +80,9 @@ | ||
80 | 80 | // create the container instance |
81 | 81 | const instance = await this._loadActor(idHash) |
82 | 82 | |
83 | 83 | // send the intialization message |
84 | - await instance.create(message) | |
84 | + instance.create(message) | |
85 | 85 | return instance.mintCap() |
86 | 86 | } |
87 | 87 | |
88 | 88 | // get a hash from a POJO |
scheduler.js | ||
---|---|---|
@@ -103,14 +103,9 @@ | ||
103 | 103 | return ticks |
104 | 104 | } |
105 | 105 | |
106 | 106 | // 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 () { | |
113 | 108 | // if there are no instances, clear any remaining waits |
114 | 109 | if (!this.instances.size) { |
115 | 110 | this._waits.forEach(wait => wait.resolve()) |
116 | 111 | this._waits = [] |
tests/index.js | ||
---|---|---|
@@ -299,9 +299,9 @@ | ||
299 | 299 | |
300 | 300 | class testVMContainerB extends BaseContainer { |
301 | 301 | onCreation (m) { |
302 | 302 | const cap = m.caps[0] |
303 | - return this.actor.send(cap, new Message({data: 'test'})) | |
303 | + this.actor.send(cap, new Message({data: 'test'})) | |
304 | 304 | } |
305 | 305 | |
306 | 306 | static get typeId () { |
307 | 307 | return 8 |
Built with git-ssb-web