git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 9ff63d468409beadacd8b12f0eddf4160cecf81e

generelize ports

wanderer committed on 5/22/2017, 9:27:33 PM
Parent: ea9456b0cd659d6f9a4f7a039e4207d594c292e4

Files changed

exoInterface.jschanged
portManager.jschanged
exoInterface.jsView
@@ -41,12 +41,20 @@
4141 }
4242 })
4343 }
4444
45+ /**
46+ * starts the container
47+ * @returns {Promise}
48+ */
4549 start () {
4650 return this.ports.start()
4751 }
4852
53+ /**
54+ * adds a message to this containers message queue
55+ * @param {Message} message
56+ */
4957 queue (message) {
5058 message._hops++
5159 this.ports.queue(message)
5260 if (this.containerState !== 'running') {
portManager.jsView
@@ -105,15 +105,15 @@
105105 return portRef
106106 }
107107
108108 // waits till all ports have reached a threshold tick count
109- wait (threshold, fromPort) {
109+ wait (threshold, fromPort = this.entryPort, ports = this._portMap) {
110110 // find the ports that have a smaller tick count then the threshold tick count
111- const unkownPorts = [...this._portMap].filter(([portRef, port]) => {
111+ const unkownPorts = [...ports].filter(([portRef, port]) => {
112112 return port.ticks < threshold && fromPort !== portRef
113113 })
114114
115- const promises = unkownPorts.map(async ([portRef, port]) => {
115+ const promises = unkownPorts.map(async([portRef, port]) => {
116116 // update the port's tick count
117117 port.ticks = await this.hypervisor.wait(portRef, threshold, this.entryPort)
118118 })
119119
@@ -121,9 +121,9 @@
121121 }
122122
123123 async getNextMessage () {
124124 if (this._portMap.size) {
125- await this.wait(this.exoInterface.ticks, this.entryPort)
125+ await this.wait(this.exoInterface.ticks)
126126 const portMap = [...this._portMap].reduce(messageArbiter)
127127 return portMap[1].shift()
128128 }
129129 }

Built with git-ssb-web