Repository navigation
Expand file tree
/
Copy pathenvy.js
More file actions
103 lines (67 loc) · 1.4 KB
/
Copy pathenvy.js
File metadata and controls
103 lines (67 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
jsio('import .envy.internal');
jsio('import .envy.Queue, .envy.Semaphore');
exports.spawn = envy.internal.spawn;
exports.sleep = envy.internal.sleep;
exports.Queue = envy.Queue;
exports.Semaphore = envy.Semaphore;
exports.wrapLogger = envy.internal.wrapLogger
/*
var _spawn = [];
function spawner() {
var errs = [];
while (_spawn.length) {
var fullArgs = _spawn.shift()
var coro = coroutine.create.apply(coroutine, fullArgs);
switchTo(coro);
}
}
function switchTo(coro) {
var yieldReason;
if (yieldReason = coroutine.resume(coro)) {
yieldReason.action();
}
}
var YieldReason= Class(function() {
this.action = function() {
}
})
var YieldWait = Class(function() {
this.init = function(ms) {
this._waitTime = ms;
}
this.action = function() {
}
});
green.spawn(lopy);
function loopy() {
while(true) {
green.sleep(0);
}
}
exports.spawn = function(target) {
if (typeof(target) != "function") {
throw new Error("First argument must be a function");
}
_spawn.push(arguments);
if (_spawn.length == 1) {
setTimeout(spawner, 0);
}
}
green = {}
green.spawn(...)
green.wait(...)
green.listen(interface, port)
green.connect(hostname, port)
green.Event
put
get
green.Queue
put
get
green.Semaphore
var Hub =
Socket {
read(...)
send(...)
}
*/