git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 3146cb3249c2ab000ed44d4712910ff42fd0d5c1

update the actors age in inbox

wanderer committed on 12/11/2017, 10:49:38 PM
Parent: bc308a00381563261f0f7ecf1d231d19e2dfbc52

Files changed

actor.jschanged
inbox.jschanged
actor.jsView
@@ -70,14 +70,8 @@
7070 while (1) {
7171 const message = await this.inbox.nextMessage()
7272 if (!message) break
7373
74- // if the message we recived had more ticks then we currently have then
75- // update it
76- if (message._fromTicks > this.ticks) {
77- this.ticks = message._fromTicks
78- this.hypervisor.scheduler.update(this)
79- }
8074 // run the next message
8175 await this.runMessage(message)
8276 // wait for state ops to finish
8377 await this.state.done()
@@ -129,11 +123,8 @@
129123 * @param {String} method - which method to run
130124 * @returns {Promise}
131125 */
132126 async runMessage (message, method = 'onMessage') {
133- const responseCap = message.responseCap
134- delete message.responseCap
135-
136127 let result
137128 try {
138129 result = await this.container[method](message)
139130 } catch (e) {
@@ -143,10 +134,10 @@
143134 exceptionError: e
144135 }
145136 }
146137
147- if (responseCap) {
148- this.send(responseCap, new Message({
138+ if (message.responseCap) {
139+ this.send(message.responseCap, new Message({
149140 data: result
150141 }))
151142 }
152143 }
inbox.jsView
@@ -90,12 +90,25 @@
9090 timeout += this.actor.ticks
9191 let oldestTime = this.hypervisor.scheduler.leastNumberOfTicks(this.actor.id)
9292
9393 while (true) {
94- if (message && message._fromTicks < timeout) {
95- timeout = message._fromTicks
94+ if (message) {
95+ // if the message we recived had more ticks then we currently have then
96+ // update our ticks to it, since we jumped forward in time
97+ if (message._fromTicks > this.actor.ticks) {
98+ this.actor.ticks = message._fromTicks
99+ this.hypervisor.scheduler.update(this.actor)
100+ }
101+
102+ // if there is a message that is "older" then the timeout, the lower
103+ // the timeout to the oldest message
104+ if (message._fromTicks < timeout) {
105+ timeout = message._fromTicks
106+ }
96107 }
97108
109+ // if all actors are "older" then the time out then stop waiting for messages
110+ // since we konw that we can not receive one
98111 if (oldestTime >= timeout) {
99112 break
100113 }
101114

Built with git-ssb-web