You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-21Lines changed: 21 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
Experiment to reproduce erlang style processes in browser. The api follows the one from Erlang. All are found on the `Scheduler` class
1
+
Experiment to reproduce erlang style processes in browser. The api follows the one from Erlang. All are found on the `ProcessSystem` class
2
2
3
3
4
4
### Running Examples
@@ -13,35 +13,35 @@ to each other.
13
13
14
14
#### Usage
15
15
16
-
* First, import the Scheduler create a new instance of one.
16
+
* First, import the ProcessSystem create a new instance of one.
17
17
```javascript
18
-
import { Scheduler } from"processes";
19
-
letscheduler=newScheduler();
18
+
import { ProcessSystem } from"processes";
19
+
letsystem=newProcessSystem();
20
20
```
21
21
22
-
* Now you can spawn processes using the scheduler.
22
+
* Now you can spawn processes using the system.
23
23
24
24
A process will switch to other processes when yield is used and will run until it completes.
25
25
26
26
```javascript
27
-
var pid1 =scheduler.spawn(function*(){
27
+
var pid1 =system.spawn(function*(){
28
28
while(true){
29
29
30
-
yieldscheduler.receive(function(value){
30
+
yieldsystem.receive(function(value){
31
31
returnconsole.log(value);
32
32
});
33
33
34
-
scheduler.send(pid2, "message from 1");
34
+
system.send(pid2, "message from 1");
35
35
}
36
36
});
37
37
38
-
scheduler.register("Sally", pid1);
38
+
system.register("Sally", pid1);
39
39
40
-
var pid2 =scheduler.spawn(function*(){
40
+
var pid2 =system.spawn(function*(){
41
41
while(true){
42
-
scheduler.send("Sally", "message from 2");
42
+
system.send("Sally", "message from 2");
43
43
44
-
yieldscheduler.receive(function(value){
44
+
yieldsystem.receive(function(value){
45
45
returnconsole.log(value);
46
46
});
47
47
}
@@ -51,7 +51,7 @@ to each other.
51
51
52
52
### API
53
53
54
-
*Scheduler
54
+
*ProcessSystem
55
55
*`spawn(fun*) : pid`- Starts a process represented by the given generator function
56
56
* `spawn(module, fun, args) : pid` - Starts a process using the generator function from the specified module
57
57
* `link(pid) : void` - links the current process with the process from the given pid
@@ -76,7 +76,7 @@ to each other.
76
76
* `erase(key)` - Removes the key and the associated value from the current process`s dictionary
77
77
* `erase()` - Removes all entries from the current process's dictionary
78
78
79
-
* `Scheduler.run(fun, args, context = null)` - A static generator function used to wrap a normal function or generator. If fun is a function, it returns the value, if it's a generator, then it delegates yielding to the generator.
79
+
* `ProcessSystem.run(fun, args, context = null)` - A static generator function used to wrap a normal function or generator. If fun is a function, it returns the value, if it's a generator, then it delegates yielding to the generator.
80
80
81
81
* GenServer
82
82
* `start(module, args)` - Starts a GenServer with the given module and args
@@ -94,8 +94,8 @@ to each other.
94
94
An example of a Stack using a GenServer
95
95
96
96
```javascript
97
-
import { Scheduler, GenServer } from "processes";
98
-
self.scheduler=self.scheduler||newScheduler();
97
+
import { ProcessSystem, GenServer } from "processes";
0 commit comments