Commit 381ecaab16e8fc78457b956f74843ae172ca686e
move send to hypervisor
wanderer committed on 7/6/2017, 6:43:46 PMParent: 391c4a37244278cb64547f788593269dc60b283a
Files changed
index.js | changed |
kernel.js | changed |
index.js | ||
---|---|---|
@@ -41,8 +41,19 @@ | ||
41 | 41 | return this.graph.get(this.state, `${port.destId}/ports/${port.destName}`) |
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
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 | + | |
45 | 56 | // loads an instance of a container from the state |
46 | 57 | async _loadInstance (id) { |
47 | 58 | const state = await this.graph.get(this.state, id) |
48 | 59 | const container = this._containerTypes[state.type] |
kernel.js | ||
---|---|---|
@@ -162,24 +162,16 @@ | ||
162 | 162 | * sends a message to a given port |
163 | 163 | * @param {Object} portRef - the port |
164 | 164 | * @param {Message} message - the message |
165 | 165 | */ |
166 | - async send (port, message) { | |
166 | + send (port, message) { | |
167 | 167 | message._hops++ |
168 | 168 | // set the port that the message came from |
169 | 169 | message._fromTicks = this.ticks |
170 | 170 | this.ports.removeSentPorts(message) |
171 | 171 | |
172 | 172 | // if (this.currentMessage !== message && !message.responsePort) { |
173 | 173 | // this.currentMessage._addSubMessage(message) |
174 | 174 | // } |
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) | |
184 | 176 | } |
185 | 177 | } |
Built with git-ssb-web