git ssb

0+

wanderer🌟 / js-primea-hypervisor



Commit db06b3c2442cea31e0706a4c186e8cc21b06d368

rename createInstance -> createActor

wanderer committed on 11/21/2017, 7:54:10 PM
Parent: 455f5db59297ab334a58c1589e8743cebdab3817

Files changed

actor.jschanged
index.jschanged
tests/index.jschanged
actor.jsView
@@ -121,11 +121,11 @@
121121 this.ticks += count
122122 this.hypervisor.scheduler.update(this)
123123 }
124124
125- createInstance (type, message) {
125+ createActor (type, message) {
126126 const id = this.generateNextId()
127- return this.hypervisor.createInstance(type, message, id)
127+ return this.hypervisor.createActor(type, message, id)
128128 }
129129
130130 generateNextId () {
131131 const id = {
index.jsView
@@ -1,5 +1,5 @@
1-const Kernel = require('./actor.js')
1+const Actor = require('./actor.js')
22 const Scheduler = require('./scheduler.js')
33
44 module.exports = class Hypervisor {
55 /**
@@ -30,10 +30,10 @@
3030 async _loadInstance (id) {
3131 const state = await this.tree.get(id, true)
3232 const container = this._containerTypes[state.value.type]
3333
34- // create a new kernel instance
35- const kernel = new Kernel({
34+ // create a new actor instance
35+ const actor = new Actor({
3636 hypervisor: this,
3737 state: state.value,
3838 node: state.node,
3939 code: state.value.code,
@@ -41,10 +41,10 @@
4141 id: id
4242 })
4343
4444 // save the newly created instance
45- this.scheduler.update(kernel)
46- return kernel
45+ this.scheduler.update(actor)
46+ return actor
4747 }
4848
4949 /**
5050 * gets an existsing container instances
@@ -64,14 +64,14 @@
6464 }
6565 }
6666
6767 /**
68- * creates an instance of a container
68+ * creates an instance of an Actor
6969 * @param {Integer} type - the type id for the container
70- * @param {Object} message - an intial [message](https://github.com/primea/js-primea-message) to send newly created instance
71- * @param {Object} id - the id for the instance
70+ * @param {Object} message - an intial [message](https://github.com/primea/js-primea-message) to send newly created actor
71+ * @param {Object} id - the id for the actor
7272 */
73- async createInstance (type, message, id = {nonce: this.nonce, parent: null}) {
73+ async createActor (type, message, id = {nonce: this.nonce, parent: null}) {
7474 const encoded = encodedID(id)
7575 this.nonce++
7676 const idHash = await this._getHashFromObj(encoded)
7777 const state = {
tests/index.jsView
@@ -34,9 +34,9 @@
3434
3535 const hypervisor = new Hypervisor(tree)
3636 hypervisor.registerContainer(testVMContainer)
3737
38- let rootCap = await hypervisor.createInstance(testVMContainer.typeId, new Message())
38+ let rootCap = await hypervisor.createActor(testVMContainer.typeId, new Message())
3939
4040 message = new Message()
4141 hypervisor.send(rootCap, message)
4242
@@ -87,10 +87,10 @@
8787 const hypervisor = new Hypervisor(tree)
8888 hypervisor.registerContainer(testVMContainerA)
8989 hypervisor.registerContainer(testVMContainerB)
9090
91- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
92- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
91+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
92+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
9393 caps: [capB]
9494 }))
9595
9696 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -129,14 +129,14 @@
129129 const hypervisor = new Hypervisor(tree)
130130 hypervisor.registerContainer(testVMContainerA)
131131 hypervisor.registerContainer(testVMContainerB)
132132
133- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
134- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
133+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
134+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
135135 caps: [capB]
136136 }))
137137
138- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
138+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
139139 caps: [capB]
140140 }))
141141
142142 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -182,14 +182,14 @@
182182 const hypervisor = new Hypervisor(tree)
183183 hypervisor.registerContainer(testVMContainerA)
184184 hypervisor.registerContainer(testVMContainerB)
185185
186- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
187- hypervisor.createInstance(testVMContainerA.typeId, new Message({
186+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
187+ hypervisor.createActor(testVMContainerA.typeId, new Message({
188188 caps: [capB]
189189 }))
190190
191- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
191+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
192192 caps: [capB]
193193 }))
194194
195195 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -233,10 +233,10 @@
233233 const hypervisor = new Hypervisor(tree)
234234 hypervisor.registerContainer(testVMContainerA)
235235 hypervisor.registerContainer(testVMContainerB)
236236
237- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
238- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
237+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
238+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
239239 caps: [capB]
240240 }))
241241
242242 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -281,10 +281,10 @@
281281 const hypervisor = new Hypervisor(tree)
282282 hypervisor.registerContainer(testVMContainerA)
283283 hypervisor.registerContainer(testVMContainerB)
284284
285- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
286- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
285+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
286+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
287287 caps: [capB]
288288 }))
289289
290290 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -307,9 +307,9 @@
307307 onCreation (m) {
308308 message = new Message()
309309 const cap = this.kernel.mintCap()
310310 message.caps.push(cap)
311- return this.kernel.createInstance(testVMContainerB.typeId, message)
311+ return this.kernel.createActor(testVMContainerB.typeId, message)
312312 }
313313
314314 onMessage (m) {
315315 t.true(m, 'should recive a response message')
@@ -330,9 +330,9 @@
330330 const hypervisor = new Hypervisor(tree)
331331 hypervisor.registerContainer(testVMContainerA)
332332 hypervisor.registerContainer(testVMContainerB)
333333
334- await hypervisor.createInstance(testVMContainerA.typeId, new Message())
334+ await hypervisor.createActor(testVMContainerA.typeId, new Message())
335335
336336 const stateRoot = await hypervisor.createStateRoot(Infinity)
337337
338338 t.deepEquals(stateRoot, expectedState, 'expected root!')
@@ -389,10 +389,10 @@
389389 const hypervisor = new Hypervisor(tree)
390390 hypervisor.registerContainer(testVMContainerA)
391391 hypervisor.registerContainer(testVMContainerB)
392392
393- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
394- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
393+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
394+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
395395 caps: [capB]
396396 }))
397397
398398 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -446,18 +446,18 @@
446446 const hypervisor = new Hypervisor(tree)
447447 hypervisor.registerContainer(testVMContainerA)
448448 hypervisor.registerContainer(testVMContainerB)
449449
450- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
450+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
451451 hypervisor.send(capB, new Message({
452452 data: 'first'
453453 }))
454- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
454+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
455455 caps: [capB],
456456 data: 'second'
457457 }))
458458
459- await hypervisor.createInstance(testVMContainerA.typeId, new Message({
459+ await hypervisor.createActor(testVMContainerA.typeId, new Message({
460460 caps: [capB],
461461 data: 'third'
462462 }))
463463
@@ -501,10 +501,10 @@
501501 const hypervisor = new Hypervisor(tree)
502502 hypervisor.registerContainer(testVMContainerA)
503503 hypervisor.registerContainer(testVMContainerB)
504504
505- let capA = await hypervisor.createInstance(testVMContainerA.typeId, new Message())
506- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
505+ let capA = await hypervisor.createActor(testVMContainerA.typeId, new Message())
506+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
507507
508508 await hypervisor.send(capA, new Message({caps: [capB]}))
509509
510510 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -552,10 +552,10 @@
552552 const hypervisor = new Hypervisor(tree)
553553 hypervisor.registerContainer(testVMContainerA)
554554 hypervisor.registerContainer(testVMContainerB)
555555
556- let capA = await hypervisor.createInstance(testVMContainerA.typeId, new Message())
557- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
556+ let capA = await hypervisor.createActor(testVMContainerA.typeId, new Message())
557+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
558558
559559 await hypervisor.send(capA, new Message({caps: [capB]}))
560560
561561 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -617,11 +617,11 @@
617617 const hypervisor = new Hypervisor(tree)
618618 hypervisor.registerContainer(testVMContainerA)
619619 hypervisor.registerContainer(testVMContainerB)
620620
621- let capA = await hypervisor.createInstance(testVMContainerA.typeId, new Message())
622- let capB1 = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
623- let capB2 = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
621+ let capA = await hypervisor.createActor(testVMContainerA.typeId, new Message())
622+ let capB1 = await hypervisor.createActor(testVMContainerB.typeId, new Message())
623+ let capB2 = await hypervisor.createActor(testVMContainerB.typeId, new Message())
624624
625625 await hypervisor.send(capA, new Message({caps: [capB1, capB2]}))
626626
627627 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -681,11 +681,11 @@
681681 const hypervisor = new Hypervisor(tree)
682682 hypervisor.registerContainer(testVMContainerA)
683683 hypervisor.registerContainer(testVMContainerB)
684684
685- let capA = await hypervisor.createInstance(testVMContainerA.typeId, new Message())
686- let capB1 = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
687- let capB2 = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
685+ let capA = await hypervisor.createActor(testVMContainerA.typeId, new Message())
686+ let capB1 = await hypervisor.createActor(testVMContainerB.typeId, new Message())
687+ let capB2 = await hypervisor.createActor(testVMContainerB.typeId, new Message())
688688
689689 await hypervisor.send(capA, new Message({caps: [capB1, capB2]}))
690690
691691 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -745,11 +745,11 @@
745745 const hypervisor = new Hypervisor(tree)
746746 hypervisor.registerContainer(testVMContainerA)
747747 hypervisor.registerContainer(testVMContainerB)
748748
749- let capA = await hypervisor.createInstance(testVMContainerA.typeId, new Message())
750- let capB1 = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
751- let capB2 = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
749+ let capA = await hypervisor.createActor(testVMContainerA.typeId, new Message())
750+ let capB1 = await hypervisor.createActor(testVMContainerB.typeId, new Message())
751+ let capB2 = await hypervisor.createActor(testVMContainerB.typeId, new Message())
752752
753753 await hypervisor.send(capA, new Message({caps: [capB1, capB2]}))
754754
755755 const stateRoot = await hypervisor.createStateRoot(Infinity)
@@ -805,11 +805,11 @@
805805 hypervisor.registerContainer(testVMContainerA)
806806 hypervisor.registerContainer(testVMContainerB)
807807 hypervisor.registerContainer(testVMContainerC)
808808
809- let capA = await hypervisor.createInstance(testVMContainerA.typeId, new Message())
810- let capB = await hypervisor.createInstance(testVMContainerB.typeId, new Message())
811- let capC = await hypervisor.createInstance(testVMContainerC.typeId, new Message())
809+ let capA = await hypervisor.createActor(testVMContainerA.typeId, new Message())
810+ let capB = await hypervisor.createActor(testVMContainerB.typeId, new Message())
811+ let capC = await hypervisor.createActor(testVMContainerC.typeId, new Message())
812812
813813 await Promise.all([
814814 hypervisor.send(capA, new Message()),
815815 hypervisor.send(capB, new Message()),

Built with git-ssb-web