git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit 9fb034bef38565313b13d8e7de173a14de9812df

added option param to container register

wanderer committed on 5/30/2017, 11:32:12 PM
Parent: ccb48716869c61d77e5c9797dab1dfde9f8bf4f8

Files changed

exoInterface.jschanged
index.jschanged
package.jsonchanged
portManager.jschanged
exoInterface.jsView
@@ -31,9 +31,9 @@
3131 exoInterface: this
3232 }, opts))
3333
3434 this._waitingMap = new Map()
35- this.container = new opts.Container(this)
35+ this.container = new opts.container.Constructor(this, opts.container.args)
3636
3737 // once we get an result we run the next message
3838 this.on('result', this._runNextMessage)
3939
index.jsView
@@ -70,13 +70,13 @@
7070 * @param {Object} the entry port
7171 * @param {Object} the parent port
7272 */
7373 async createInstance (type, state, entryPort = null, parentPort) {
74- const Container = this._containerTypes[type]
74+ const container = this._containerTypes[type]
7575
7676 if (!state) {
7777 state = {
78- '/': Container.createState()
78+ '/': container.Constructor.createState()
7979 }
8080 }
8181
8282 // create a new kernel instance
@@ -84,9 +84,9 @@
8484 entryPort: entryPort,
8585 parentPort: parentPort,
8686 hypervisor: this,
8787 state: state,
88- Container: Container
88+ container: container
8989 })
9090
9191 // save the newly created instance
9292 this._containerInstances.set(entryPort, exoInterface)
@@ -107,11 +107,15 @@
107107 }
108108
109109 /**
110110 * regirsters a container with the hypervisor
111- * @param {String} the name of the type
112- * @param {Class} a Class for instantiating the container
111+ * @param {String}i type - the name of the type
112+ * @param {Class} Constructor - a Class for instantiating the container
113+ * @param {*} args - any args that the contructor takes
113114 */
114- registerContainer (type, vm) {
115- this._containerTypes[type] = vm
115+ registerContainer (type, Constructor, args) {
116+ this._containerTypes[type] = {
117+ Constructor: Constructor,
118+ args: args
119+ }
116120 }
117121 }
package.jsonView
@@ -41,8 +41,9 @@
4141 "documentation": "^4.0.0-rc.1",
4242 "ipfs": "^0.23.1",
4343 "istanbul": "^1.1.0-alpha.1",
4444 "primea-message": "0.0.1",
45+ "primea-wasm-container": "0.0.0",
4546 "standard": "10.0.2",
4647 "tape": "^4.5.1"
4748 }
4849 }
portManager.jsView
@@ -158,11 +158,11 @@
158158 * @param {*} data - the data to populate the initail state with
159159 * @returns {Object} the newly created port
160160 */
161161 create (type, data) {
162- const Container = this.hypervisor._containerTypes[type]
162+ const container = this.hypervisor._containerTypes[type]
163163 return this._createPortObject(type, {
164- '/': Container.createState(data)
164+ '/': container.Constructor.createState(data)
165165 })
166166 }
167167
168168 /**

Built with git-ssb-web