Skip to content

Commit

Permalink
move send to hypervisor
Browse files Browse the repository at this point in the history
  • Loading branch information
wanderer committed Jul 6, 2017
1 parent 391c4a3 commit 381ecaa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
11 changes: 11 additions & 0 deletions index.js
Expand Up @@ -42,6 +42,17 @@ module.exports = class Hypervisor {
}
}

async send (port, message) {
if (port.destId) {
const id = port.destId
const instance = await this.getInstance(id)
return instance.queue(port.destName, message)
} else {
// port is unbound
port.destPort.messages.push(message)
}
}

// loads an instance of a container from the state
async _loadInstance (id) {
const state = await this.graph.get(this.state, id)
Expand Down
12 changes: 2 additions & 10 deletions kernel.js
Expand Up @@ -163,7 +163,7 @@ module.exports = class Kernel {
* @param {Object} portRef - the port
* @param {Message} message - the message
*/
async send (port, message) {
send (port, message) {
message._hops++
// set the port that the message came from
message._fromTicks = this.ticks
Expand All @@ -172,14 +172,6 @@ module.exports = class Kernel {
// if (this.currentMessage !== message && !message.responsePort) {
// this.currentMessage._addSubMessage(message)
// }

if (port.destId) {
const id = port.destId
const instance = await this.hypervisor.getInstance(id)
return instance.queue(port.destName, message)
} else {
// port is unbound
port.destPort.messages.push(message)
}
return this.hypervisor.send(port, message)
}
}

0 comments on commit 381ecaa

Please sign in to comment.