git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 381ecaab16e8fc78457b956f74843ae172ca686e

move send to hypervisor

wanderer committed on 7/6/2017, 6:43:46 PM
Parent: 391c4a37244278cb64547f788593269dc60b283a

Files changed

index.jschanged
kernel.jschanged
index.jsView
@@ -41,8 +41,19 @@
4141 return this.graph.get(this.state, `${port.destId}/ports/${port.destName}`)
4242 }
4343 }
4444
45+ async send (port, message) {
46+ if (port.destId) {
47+ const id = port.destId
48+ const instance = await this.getInstance(id)
49+ return instance.queue(port.destName, message)
50+ } else {
51+ // port is unbound
52+ port.destPort.messages.push(message)
53+ }
54+ }
55+
4556 // loads an instance of a container from the state
4657 async _loadInstance (id) {
4758 const state = await this.graph.get(this.state, id)
4859 const container = this._containerTypes[state.type]
kernel.jsView
@@ -162,24 +162,16 @@
162162 * sends a message to a given port
163163 * @param {Object} portRef - the port
164164 * @param {Message} message - the message
165165 */
166- async send (port, message) {
166+ send (port, message) {
167167 message._hops++
168168 // set the port that the message came from
169169 message._fromTicks = this.ticks
170170 this.ports.removeSentPorts(message)
171171
172172 // if (this.currentMessage !== message && !message.responsePort) {
173173 // this.currentMessage._addSubMessage(message)
174174 // }
175-
176- if (port.destId) {
177- const id = port.destId
178- const instance = await this.hypervisor.getInstance(id)
179- return instance.queue(port.destName, message)
180- } else {
181- // port is unbound
182- port.destPort.messages.push(message)
183- }
175+ return this.hypervisor.send(port, message)
184176 }
185177 }

Built with git-ssb-web