Skip to content

Commit

Permalink
Merge pull request #2 from dfinity/small-fixes
Browse files Browse the repository at this point in the history
Small fixes
  • Loading branch information
wanderer committed Mar 6, 2018
2 parents 426c0bb + 19b980f commit 888b875
Show file tree
Hide file tree
Showing 10 changed files with 84 additions and 167 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
testdb/
testdb/
*.sublime-*
2 changes: 1 addition & 1 deletion customTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function mergeTypeSections (json) {

const {value: type} = iterator.next()
const {value: imports = {entries: []}} = iterator.next()
const {value: functions} = iterator.next()
const {value: functions = {entries: []}} = iterator.next()
functions.entries.forEach((typeIndex, funcIndex) => {
let customIndex = mappedFuncs.get(funcIndex)
if (customIndex === undefined) {
Expand Down
26 changes: 7 additions & 19 deletions docs/actor.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
### Table of Contents

- [constructor](#constructor)
- [queue](#queue)
- [shutdown](#shutdown)
- [startup](#startup)
- [runMessage](#runmessage)
Expand All @@ -13,7 +12,7 @@

## constructor

[actor.js:15-25](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L15-L25 "Source code on GitHub")
[actor.js:11-18](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L11-L18 "Source code on GitHub")

the Actor manages the varous message passing functions and provides
an interface for the containers to use
Expand All @@ -26,32 +25,21 @@ an interface for the containers to use
- `opts.hypervisor` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the instance of the hypervisor
- `opts.container` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the container constuctor and argments

## queue

[actor.js:32-39](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L32-L39 "Source code on GitHub")

adds a message to this actor's message queue

**Parameters**

- `message` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
- `portName` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

## shutdown

[actor.js:89-92](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L89-L92 "Source code on GitHub")
[actor.js:23-29](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L23-L29 "Source code on GitHub")

Runs the shutdown routine for the actor

## startup

[actor.js:97-99](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L97-L99 "Source code on GitHub")
[actor.js:34-36](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L34-L36 "Source code on GitHub")

Runs the startup routine for the actor

## runMessage

[actor.js:107-114](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L107-L114 "Source code on GitHub")
[actor.js:44-56](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L44-L56 "Source code on GitHub")

run the Actor with a given message

Expand All @@ -64,7 +52,7 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/

## incrementTicks

[actor.js:120-123](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L120-L123 "Source code on GitHub")
[actor.js:62-64](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L62-L64 "Source code on GitHub")

updates the number of ticks that the actor has run

Expand All @@ -74,7 +62,7 @@ updates the number of ticks that the actor has run

## createActor

[actor.js:130-133](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L130-L133 "Source code on GitHub")
[actor.js:71-74](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L71-L74 "Source code on GitHub")

creates an actor

Expand All @@ -86,7 +74,7 @@ creates an actor

## send

[actor.js:150-155](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/actor.js#L150-L155 "Source code on GitHub")
[actor.js:91-96](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/actor.js#L91-L96 "Source code on GitHub")

sends a message to a given port

Expand Down
28 changes: 8 additions & 20 deletions docs/hypervisor.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

- [constructor](#constructor)
- [send](#send)
- [getActor](#getactor)
- [createActor](#createactor)
- [createStateRoot](#createstateroot)
- [registerContainer](#registercontainer)

## constructor

[index.js:10-15](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L10-L15 "Source code on GitHub")
[index.js:12-17](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L12-L17 "Source code on GitHub")

The Hypervisor manages the container instances by instantiating them and
destorying them when possible. It also facilitates localating Containers
Expand All @@ -23,32 +22,21 @@ destorying them when possible. It also facilitates localating Containers

## send

[index.js:23-27](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L23-L27 "Source code on GitHub")
[index.js:25-30](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L25-L30 "Source code on GitHub")

sends a message

**Parameters**

- `message` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the [message](https://github.com/primea/js-primea-message) to send
- `messages`
- `cap` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the capabilitly used to send the message
- `message` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** the [message](https://github.com/primea/js-primea-message) to send

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** a promise that resolves once the receiving container is loaded

## getActor

[index.js:55-63](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L55-L63 "Source code on GitHub")

gets an existsing actor

**Parameters**

- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the actor's ID

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**

## createActor

[index.js:71-85](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L71-L85 "Source code on GitHub")
[index.js:65-83](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L65-L83 "Source code on GitHub")

creates an instance of an Actor

Expand All @@ -61,20 +49,20 @@ creates an instance of an Actor

## createStateRoot

[index.js:98-101](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L98-L101 "Source code on GitHub")
[index.js:98-104](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L98-L104 "Source code on GitHub")

creates a state root starting from a given container and a given number of
ticks

**Parameters**

- `ticks` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of ticks at which to create the state root (optional, default `Infinity`)
- `ticks` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of ticks at which to create the state root

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**

## registerContainer

[index.js:109-111](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/index.js#L109-L111 "Source code on GitHub")
[index.js:112-114](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/index.js#L112-L114 "Source code on GitHub")

regirsters a container with the hypervisor

Expand Down
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# API
- [Hypervisor](./hypervisor.md)
- [Kernel](./kernel.md)
- [PortManager](./portManager.md)
- [Actor](./actor.md)

## internal API's
## Internal APIs
- [Scheduler](./scheduler.md)
76 changes: 2 additions & 74 deletions docs/scheduler.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,86 +3,14 @@
### Table of Contents

- [constructor](#constructor)
- [lock](#lock)
- [update](#update)
- [getInstance](#getinstance)
- [done](#done)
- [wait](#wait)
- [leastNumberOfTicks](#leastnumberofticks)

## constructor

[scheduler.js:13-17](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L13-L17 "Source code on GitHub")
[scheduler.js:19-26](https://github.com/dfinity/js-primea/blob/21960d62467278cd5659e2eb5f80cc6ddd87e663/scheduler.js#L19-L26 "Source code on GitHub")

The Scheduler manages the actor instances and tracks how many "ticks" they
have ran.

## lock

[scheduler.js:24-34](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L24-L34 "Source code on GitHub")

locks the scheduler from clearing waits untill the lock is resolved

**Parameters**

- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

Returns **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** the resolve function to call once it to unlock

## update

[scheduler.js:40-44](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L40-L44 "Source code on GitHub")

updates an instance with a new tick count

**Parameters**

- `instance` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** an actor instance

## getInstance

[scheduler.js:56-59](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L56-L59 "Source code on GitHub")

returns an Actor instance

**Parameters**

- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**

Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**

## done

[scheduler.js:65-70](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L65-L70 "Source code on GitHub")

deletes an instance from the scheduler

**Parameters**

- `id` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the containers id

## wait

[scheduler.js:79-93](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L79-L93 "Source code on GitHub")

returns a promise that resolves once all containers have reached the given
number of ticks

**Parameters**

- `ticks` **interger** the number of ticks to wait
- `id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** optional id of the container that is waiting

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**

## leastNumberOfTicks

[scheduler.js:99-109](https://github.com/dfinity/js-primea/blob/3d3fc0d82dd65f14b8533dcd2fb881c9fbbb1bd3/scheduler.js#L99-L109 "Source code on GitHub")

returns the oldest container's ticks

**Parameters**

- `exclude`

Returns **integer**
- `hypervisor`
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
"coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
"coverage": "nyc npm test",
"lint": "standard",
"build:docs": "npm run build:docs:hypervisor && npm run build:docs:actor && npm run build:docs:scheduler && npm run build:docs:capsStore && npm run build:docs:inbox",
"build:docs": "npm run build:docs:hypervisor && npm run build:docs:actor && npm run build:docs:scheduler",
"build:docs:hypervisor": "documentation build ./index.js --github --shallow --sort-order source -f md > ./docs/hypervisor.md",
"build:docs:actor": "documentation build ./actor.js --github --shallow --sort-order source -f md > ./docs/actor.md",
"build:docs:capsStore": "documentation build ./capsStore.js --github --shallow --sort-order source -f md > ./docs/capsStore.md",
"test": "node ./tests/index.js"
"build:docs:scheduler": "documentation build ./scheduler.js --github --shallow --sort-order source -f md > ./docs/scheduler.md",
"test": "node ./tests/index.js",
"test:wasm": "node ./tests/wasmContainer.js"
},
"repository": {
"type": "git",
Expand Down
Binary file added tests/wasm/empty.wasm
Binary file not shown.
Loading

0 comments on commit 888b875

Please sign in to comment.