flok 0.0.36 → 0.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/app/drivers/chrome/build_context.rb +1 -1
- data/app/drivers/chrome/config.yml +10 -0
- data/app/drivers/chrome/pipe.rb +24 -1
- data/app/drivers/chrome/src/persist.js +29 -0
- data/app/drivers/chrome/src/sockio.js +3 -1
- data/app/drivers/chrome/src/vendor/store2.js +3 -0
- data/app/kern/callout.js +55 -0
- data/app/kern/controller.js +3 -0
- data/app/kern/crc32.js +22 -0
- data/app/kern/dispatch.js +16 -0
- data/app/kern/mod/event.js +3 -0
- data/app/kern/mod/persist.js +1 -0
- data/app/kern/mod/timer.js +5 -0
- data/app/kern/pagers/mem_pager.js +2 -0
- data/app/kern/pagers/sockio_pager.js +66 -0
- data/app/kern/pagers/spec0.js +35 -0
- data/app/kern/pagers/spec1.js +24 -0
- data/app/kern/pagers/spec2.js +31 -0
- data/app/kern/services/test.rb +7 -0
- data/app/kern/services/vm.rb +141 -0
- data/app/kern/spec_helper.js +5 -0
- data/bin/flok +27 -5
- data/docs/callout.md +8 -0
- data/docs/client_api.md +1 -1
- data/docs/compilation.md +14 -8
- data/docs/controllers.md +2 -1
- data/docs/datatypes.md +3 -1
- data/docs/environmentals.md +6 -0
- data/docs/interactive.md +6 -1
- data/docs/kernel_api.md +3 -0
- data/docs/mod/event.md +5 -1
- data/docs/mod/persist.md +14 -31
- data/docs/mod/timer.md +4 -2
- data/docs/project.md +16 -5
- data/docs/scheduling.md +1 -0
- data/docs/services.md +141 -56
- data/docs/services/vm.md +128 -0
- data/docs/services/vm/pagers.md +46 -0
- data/lib/flok/build.rb +11 -16
- data/lib/flok/platform.rb +29 -6
- data/lib/flok/project_template/app/scripts/script.js +3 -0
- data/lib/flok/project_template/app/services/service.rb +1 -0
- data/lib/flok/project_template/config/config.yml +1 -0
- data/lib/flok/project_template/config/platforms/chrome/config.yml +1 -0
- data/lib/flok/project_template/config/services.rb +1 -0
- data/lib/flok/service_compiler_templates/services.js.erb +78 -9
- data/lib/flok/services_compiler.rb +117 -20
- data/lib/flok/user_compiler.rb +14 -6
- data/lib/flok/user_compiler_templates/ctable.js.erb +10 -0
- data/lib/flok/version.rb +1 -1
- data/spec/env/etc.rb +1 -1
- data/spec/env/global.rb +2 -0
- data/spec/env/iface.rb +20 -4
- data/spec/env/kern.rb +8 -3
- data/spec/etc/cli_spec.rb +319 -165
- data/spec/etc/lib/assets/config.yml +3 -0
- data/spec/etc/lib/platform_spec.rb +14 -10
- data/spec/etc/lib/project_spec.rb +22 -0
- data/spec/etc/service_compiler/config0.rb +1 -0
- data/spec/etc/service_compiler/config1.rb +1 -0
- data/spec/etc/service_compiler/config2.rb +3 -0
- data/spec/etc/service_compiler/service0.rb +22 -6
- data/spec/etc/service_compiler/service1.rb +26 -0
- data/spec/etc/service_compiler/service_bad_type.rb +20 -0
- data/spec/etc/services_compiler_spec.rb +35 -16
- data/spec/etc/user_compiler/data.js +2 -0
- data/spec/etc/user_compiler_spec.rb +7 -1
- data/spec/iface/driver/persist_spec.rb +106 -0
- data/spec/iface/driver/pipe_spec.rb +5 -0
- data/spec/iface/kern/ping_spec.rb +4 -3
- data/spec/kern/assets/blank.rb +0 -0
- data/spec/kern/assets/service0.rb +24 -0
- data/spec/kern/assets/service1.rb +22 -0
- data/spec/kern/assets/service2.rb +27 -0
- data/spec/kern/assets/service_config0.rb +2 -0
- data/spec/kern/assets/service_config1.rb +2 -0
- data/spec/kern/assets/service_controller0.rb +13 -0
- data/spec/kern/assets/service_controller1.rb +32 -0
- data/spec/kern/assets/service_controller2.rb +38 -0
- data/spec/kern/assets/service_controller3.rb +38 -0
- data/spec/kern/assets/vm/config0.rb +2 -0
- data/spec/kern/assets/vm/config1.rb +12 -0
- data/spec/kern/assets/vm/config2.rb +12 -0
- data/spec/kern/assets/vm/config3.rb +12 -0
- data/spec/kern/assets/vm/controller0.rb +8 -0
- data/spec/kern/assets/vm/controller1.rb +18 -0
- data/spec/kern/assets/vm/controller2.rb +18 -0
- data/spec/kern/assets/vm/controller3.rb +20 -0
- data/spec/kern/assets/vm/controller4.rb +22 -0
- data/spec/kern/assets/vm/controller5.rb +22 -0
- data/spec/kern/assets/vm/controller6.rb +21 -0
- data/spec/kern/assets/vm/service0.rb +24 -0
- data/spec/kern/assets/vm/service_controller0.rb +7 -0
- data/spec/kern/callout_spec.rb +153 -0
- data/spec/kern/functions_spec.rb +29 -0
- data/spec/kern/service_controller_spec.rb +213 -0
- data/spec/kern/vm_service_spec.rb +195 -0
- metadata +98 -12
- data/app/kern/services/rest.rb +0 -310
- data/app/kern/services/timer.rb +0 -30
- data/docs/services/timer.md +0 -21
- data/spec/kern/assets/rest_service.rb +0 -20
- data/spec/kern/assets/timer_service.rb +0 -19
- data/spec/kern/timer_service_spec.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 847b5b5b82356f175e5193de663c69487bc543fc
|
4
|
+
data.tar.gz: 06b557dd275ee22398619033cc94b893eb815cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2dd662522a021063c44cfdbea4db37ea388f7d82f42108be93cd2b68507286b21650e524c9a2f99d2025781a375ae6d133383bb767e77cfa5af9642d37467f36
|
7
|
+
data.tar.gz: eed43cf8edd7d656d0364770c73468658bff40759621629f3e127627327ab7c9f03a3d3bf4200c079a5293297216fac924efb35bd259bb474bd1e97c6687ce26
|
data/Rakefile
CHANGED
@@ -67,6 +67,7 @@ namespace :build do
|
|
67
67
|
#What platform are we working with?
|
68
68
|
raise "No $PLATFORM given" unless platform = ENV["PLATFORM"]
|
69
69
|
raise "No $FLOK_ENV given" unless environment = ENV["FLOK_ENV"]
|
70
|
+
|
70
71
|
build_path = "./products/#{platform}"
|
71
72
|
|
72
73
|
Flok.build_world(build_path, platform, environment)
|
@@ -6,7 +6,7 @@ module Chrome
|
|
6
6
|
@debug = (ENV['FLOK_ENV'] == "DEBUG")
|
7
7
|
@release = (ENV['FLOK_ENV'] == "RELEASE")
|
8
8
|
Dir.chdir File.join(File.dirname(__FILE__), "../../../") do
|
9
|
-
@mods = Flok::Platform.mods(ENV['
|
9
|
+
@mods = Flok::Platform.mods(ENV['FLOK_ENV'])
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -8,6 +8,11 @@ DEBUG:
|
|
8
8
|
- controller
|
9
9
|
- debug
|
10
10
|
- sockio
|
11
|
+
- persist
|
12
|
+
- timer
|
13
|
+
defines:
|
14
|
+
- mem_pager
|
15
|
+
- sockio_pager
|
11
16
|
RELEASE:
|
12
17
|
mods:
|
13
18
|
- ui
|
@@ -16,3 +21,8 @@ RELEASE:
|
|
16
21
|
- segue
|
17
22
|
- controller
|
18
23
|
- sockio
|
24
|
+
- persist
|
25
|
+
- timer
|
26
|
+
defines:
|
27
|
+
- mem_pager
|
28
|
+
- sockio_pager
|
data/app/drivers/chrome/pipe.rb
CHANGED
@@ -2,6 +2,7 @@ require 'json'
|
|
2
2
|
require 'tempfile'
|
3
3
|
require 'securerandom'
|
4
4
|
require 'open3'
|
5
|
+
$stdout.sync = true
|
5
6
|
|
6
7
|
#Interactive pipe for testing.
|
7
8
|
#Creates a server that routes $stdin into if_dispatch and $stdout to int_dispatch.
|
@@ -33,7 +34,29 @@ class InteractiveServer
|
|
33
34
|
if results[0].include? STDIN
|
34
35
|
begin
|
35
36
|
q = gets.strip
|
36
|
-
|
37
|
+
if q == "RESTART"
|
38
|
+
inp.puts "$__RESTART__"
|
39
|
+
|
40
|
+
begin
|
41
|
+
#Wait for restart to respond 'ok'
|
42
|
+
Timeout::timeout(10) do
|
43
|
+
restart_res = out.readline
|
44
|
+
raise "Restart of phantomjs did not return '__RESTART_OK__' like expected, returned: #{restart_res.inspect}" unless restart_res == "$__RESTART_OK__\n"
|
45
|
+
end
|
46
|
+
rescue Timeout::Error
|
47
|
+
raise "Restart of boojs did not happen within 5 seconds"
|
48
|
+
rescue EOFError
|
49
|
+
#Sleep for a second to let the error pipe fill up from boojs, this error
|
50
|
+
#will then be displayed and then we will crash
|
51
|
+
sleep 3
|
52
|
+
$stderr.puts err.read
|
53
|
+
raise "boojs encountered an error"
|
54
|
+
end
|
55
|
+
|
56
|
+
puts "RESTART OK"
|
57
|
+
else
|
58
|
+
inp.puts "if_dispatch(JSON.parse('#{q}'))"
|
59
|
+
end
|
37
60
|
rescue Errno::EIO
|
38
61
|
#Can't say anything here, we don't have a pipe
|
39
62
|
exit 1
|
@@ -0,0 +1,29 @@
|
|
1
|
+
function if_per_set(ns, key, value) {
|
2
|
+
var _ns = store.namespace(ns);
|
3
|
+
_ns.set(key, value)
|
4
|
+
}
|
5
|
+
|
6
|
+
function if_per_del(ns, key) {
|
7
|
+
var _ns = store.namespace(ns);
|
8
|
+
_ns.remove(key);
|
9
|
+
}
|
10
|
+
|
11
|
+
function if_per_del_ns(ns) {
|
12
|
+
var _ns = store.namespace(ns);
|
13
|
+
_ns.clearAll();
|
14
|
+
}
|
15
|
+
|
16
|
+
function if_per_get(s, ns, key) {
|
17
|
+
function async() {
|
18
|
+
var _ns = store.namespace(ns);
|
19
|
+
var res = _ns.get(key);
|
20
|
+
int_dispatch([2, "int_per_get_res", s, res]);
|
21
|
+
}
|
22
|
+
setTimeout(async, 0);
|
23
|
+
}
|
24
|
+
|
25
|
+
function if_per_get_sync(s, ns, key) {
|
26
|
+
var _ns = store.namespace(ns);
|
27
|
+
var res = _ns.get(key);
|
28
|
+
int_dispatch([2, "int_per_get_res", s, res]);
|
29
|
+
}
|
@@ -0,0 +1,3 @@
|
|
1
|
+
/*! store2 - v2.3.0 - 2015-05-22
|
2
|
+
* Copyright (c) 2015 Nathan Bubna; Licensed MIT, GPL */
|
3
|
+
(function(t,e){var n={version:"2.3.0",areas:{},apis:{},inherit:function(t,e){for(var n in t)e.hasOwnProperty(n)||(e[n]=t[n]);return e},stringify:function(t){return void 0===t||"function"==typeof t?t+"":JSON.stringify(t)},parse:function(t){try{return JSON.parse(t)}catch(e){return t}},fn:function(t,e){n.storeAPI[t]=e;for(var i in n.apis)n.apis[i][t]=e},get:function(t,e){return t.getItem(e)},set:function(t,e,n){t.setItem(e,n)},remove:function(t,e){t.removeItem(e)},key:function(t,e){return t.key(e)},length:function(t){return t.length},clear:function(t){t.clear()},Store:function(t,e,i){var r=n.inherit(n.storeAPI,function(t,e,n){return 0===arguments.length?r.getAll():void 0!==e?r.set(t,e,n):"string"==typeof t?r.get(t):t?r.setAll(t,e):r.clear()});r._id=t;try{var s="_safariPrivate_";e.setItem(s,"sucks"),r._area=e,e.removeItem(s)}catch(a){}return r._area||(r._area=n.inherit(n.storageAPI,{items:{},name:"fake"})),r._ns=i||"",n.areas[t]||(n.areas[t]=r._area),n.apis[r._ns+r._id]||(n.apis[r._ns+r._id]=r),r},storeAPI:{area:function(t,e){var i=this[t];return i&&i.area||(i=n.Store(t,e,this._ns),this[t]||(this[t]=i)),i},namespace:function(t,e){if(!t)return this._ns?this._ns.substring(0,this._ns.length-1):"";var i=t,r=this[i];return r&&r.namespace||(r=n.Store(this._id,this._area,this._ns+i+"."),this[i]||(this[i]=r),e||r.area("session",n.areas.session)),r},isFake:function(){return"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(t){return this._area.has?this._area.has(this._in(t)):!!(this._in(t)in this._area)},size:function(){return this.keys().length},each:function(t,e){for(var i=0,r=n.length(this._area);r>i;i++){var s=this._out(n.key(this._area,i));if(void 0!==s&&t.call(this,s,e||this.get(s))===!1)break;r>n.length(this._area)&&(r--,i--)}return e||this},keys:function(){return this.each(function(t,e){e.push(t)},[])},get:function(t,e){var i=n.get(this._area,this._in(t));return null!==i?n.parse(i):e||i},getAll:function(){return this.each(function(t,e){e[t]=this.get(t)},{})},set:function(t,e,i){var r=this.get(t);return null!=r&&i===!1?e:n.set(this._area,this._in(t),n.stringify(e),i)||r},setAll:function(t,e){var n,i;for(var r in t)i=t[r],this.set(r,i,e)!==i&&(n=!0);return n},remove:function(t){var e=this.get(t);return n.remove(this._area,this._in(t)),e},clear:function(){return this._ns?this.each(function(t){n.remove(this._area,this._in(t))},1):n.clear(this._area),this},clearAll:function(){var t=this._area;for(var e in n.areas)n.areas.hasOwnProperty(e)&&(this._area=n.areas[e],this.clear());return this._area=t,this},_in:function(t){return"string"!=typeof t&&(t=n.stringify(t)),this._ns?this._ns+t:t},_out:function(t){return this._ns?t&&0===t.indexOf(this._ns)?t.substring(this._ns.length):void 0:t}},storageAPI:{length:0,has:function(t){return this.items.hasOwnProperty(t)},key:function(t){var e=0;for(var n in this.items)if(this.has(n)&&t===e++)return n},setItem:function(t,e){this.has(t)||this.length++,this.items[t]=e},removeItem:function(t){this.has(t)&&(delete this.items[t],this.length--)},getItem:function(t){return this.has(t)?this.items[t]:null},clear:function(){for(var t in this.list)this.removeItem(t)},toString:function(){return this.length+" items in "+this.name+"Storage"}}};t.store&&(n.conflict=t.store);var i=n.Store("local",function(){try{return localStorage}catch(t){}}());i.local=i,i._=n,i.area("session",function(){try{return sessionStorage}catch(t){}}()),t.store=i,"function"==typeof e&&void 0!==e.amd?e(function(){return i}):"undefined"!=typeof module&&module.exports&&(module.exports=i)})(this,this.define);
|
data/app/kern/callout.js
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
callout_tick = 0;
|
2
|
+
callout_queue = {};
|
3
|
+
|
4
|
+
function callout_wakeup() {
|
5
|
+
callout_tick += 1;
|
6
|
+
|
7
|
+
//Get an array of things that should fire now
|
8
|
+
var arr = callout_queue[callout_tick];
|
9
|
+
if (arr === undefined) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
delete callout_queue[callout_tick];
|
13
|
+
|
14
|
+
for (var i = 0; i < arr.length; ++i) {
|
15
|
+
var e = arr[i];
|
16
|
+
|
17
|
+
//Send event
|
18
|
+
var ep_ok = int_event(e.ep, e.ename, {});
|
19
|
+
|
20
|
+
//Reschedule interval if the ep still exists
|
21
|
+
if (e.interval && ep_ok) {
|
22
|
+
reg_interval(e.ep, e.ename, e.ticks);
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
function reg_timeout(ep, ename, ticks) {
|
28
|
+
//Create an array if there isn't already one
|
29
|
+
if (callout_queue[ticks+callout_tick] === undefined) {
|
30
|
+
callout_queue[ticks+callout_tick] = [];
|
31
|
+
}
|
32
|
+
|
33
|
+
//Insert an item
|
34
|
+
callout_queue[ticks+callout_tick].push({
|
35
|
+
ep: ep,
|
36
|
+
ename: ename,
|
37
|
+
ticks: ticks,
|
38
|
+
interval: false
|
39
|
+
});
|
40
|
+
}
|
41
|
+
|
42
|
+
function reg_interval(ep, ename, ticks) {
|
43
|
+
//Create an array if there isn't already one
|
44
|
+
if (callout_queue[ticks+callout_tick] === undefined) {
|
45
|
+
callout_queue[ticks+callout_tick] = [];
|
46
|
+
}
|
47
|
+
|
48
|
+
//Insert an item
|
49
|
+
callout_queue[ticks+callout_tick].push({
|
50
|
+
ep: ep,
|
51
|
+
ename: ename,
|
52
|
+
ticks: ticks,
|
53
|
+
interval: true
|
54
|
+
});
|
55
|
+
}
|
data/app/kern/controller.js
CHANGED
@@ -90,6 +90,9 @@ function _embed(vc_name, sp, context, event_gw) {
|
|
90
90
|
//Register the event handler callback
|
91
91
|
reg_evt(base, controller_event_callback);
|
92
92
|
|
93
|
+
//Call __init__
|
94
|
+
cte.__init__(base);
|
95
|
+
|
93
96
|
//Call the on_entry function with the base address
|
94
97
|
cte.actions[action].on_entry(base);
|
95
98
|
|
data/app/kern/crc32.js
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
function crc_init() {
|
2
|
+
var c;
|
3
|
+
crc_table = [];
|
4
|
+
for (var n = 0; n < 256; n++) {
|
5
|
+
c = n;
|
6
|
+
for (var k = 0; k < 8; k++) {
|
7
|
+
c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
8
|
+
}
|
9
|
+
crc_table[n] = c;
|
10
|
+
}
|
11
|
+
}
|
12
|
+
crc_init();
|
13
|
+
|
14
|
+
function crc32(seed, str) {
|
15
|
+
var crc = seed ^ (-1);
|
16
|
+
|
17
|
+
for (var i = 0; i < str.length; i++) {
|
18
|
+
crc = (crc >>> 8) ^ crc_table[(crc ^ str.charCodeAt(i)) & 0xFF];
|
19
|
+
}
|
20
|
+
|
21
|
+
return (crc ^ (-1)) >>> 0;
|
22
|
+
};
|
data/app/kern/dispatch.js
CHANGED
@@ -96,6 +96,16 @@ function int_dispatch(q) {
|
|
96
96
|
gpu_q_rem -= n;
|
97
97
|
}
|
98
98
|
|
99
|
+
//Send async queue
|
100
|
+
if (async_q.length > 0) {
|
101
|
+
var out = [5];
|
102
|
+
for (var i = 0; i < async_q.length; ++i) {
|
103
|
+
out.push.apply(out, async_q[i]);
|
104
|
+
}
|
105
|
+
dump.push(out);
|
106
|
+
async_q = [];
|
107
|
+
}
|
108
|
+
|
99
109
|
if (dump.length != 0) {
|
100
110
|
if_dispatch(dump);
|
101
111
|
}
|
@@ -125,6 +135,8 @@ function ping3(arg1) {
|
|
125
135
|
SEND("cpu", "pong3");
|
126
136
|
} else if (arg1 == "gpu") {
|
127
137
|
SEND("gpu", "pong3");
|
138
|
+
} else if (arg1 == "async") {
|
139
|
+
SEND("async", "pong3");
|
128
140
|
}
|
129
141
|
}
|
130
142
|
|
@@ -139,6 +151,8 @@ function ping4(arg1) {
|
|
139
151
|
SEND("cpu", "pong4");
|
140
152
|
} else if (arg1 == "gpu") {
|
141
153
|
SEND("gpu", "pong4");
|
154
|
+
} else if (arg1 == "async") {
|
155
|
+
SEND("async", "pong4");
|
142
156
|
}
|
143
157
|
}
|
144
158
|
|
@@ -152,6 +166,7 @@ function ping4_int(arg1) {
|
|
152
166
|
++cpu_q_rem;
|
153
167
|
} else if (arg1 == "gpu") {
|
154
168
|
++gpu_q_rem;
|
169
|
+
} else if (arg1 == "async") {
|
155
170
|
}
|
156
171
|
}
|
157
172
|
|
@@ -161,6 +176,7 @@ net_q = [];
|
|
161
176
|
disk_q = [];
|
162
177
|
cpu_q = [];
|
163
178
|
gpu_q = [];
|
179
|
+
async_q = [];
|
164
180
|
|
165
181
|
//Each queue has a max # of things that can be en-queued
|
166
182
|
//These are decremented when the message is sent (not just queued)
|
data/app/kern/mod/event.js
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
//Stub
|
@@ -0,0 +1,66 @@
|
|
1
|
+
<% if @defines['sockio_pager'] %>
|
2
|
+
sockio_pager_data = {};
|
3
|
+
|
4
|
+
sockio_pager_sp = null;
|
5
|
+
sockio_pager_bp = null;
|
6
|
+
waiting_bp = null;
|
7
|
+
function sockio_pager_init(options) {
|
8
|
+
sockio_pager_sp = tels(1);
|
9
|
+
sockio_pager_bp = tels(1);
|
10
|
+
SEND("main", "if_sockio_init", options.url, sockio_pager_sp);
|
11
|
+
reg_evt(sockio_pager_bp, sockio_pager_sp_endpoint);
|
12
|
+
SEND("async", "if_sockio_fwd", sockio_pager_sp, "read_res", sockio_pager_bp);
|
13
|
+
SEND("async", "if_sockio_fwd", sockio_pager_sp, "notify", sockio_pager_bp);
|
14
|
+
}
|
15
|
+
|
16
|
+
function sockio_pager_read_sync(ns, bp, key) {
|
17
|
+
throw "sockio_pager does not support read_sync"
|
18
|
+
}
|
19
|
+
|
20
|
+
function sockio_pager_read(ns, bp, key) {
|
21
|
+
var info = {
|
22
|
+
key: key,
|
23
|
+
bp: bp
|
24
|
+
}
|
25
|
+
|
26
|
+
SEND("async", "if_sockio_send", sockio_pager_sp, "read", info);
|
27
|
+
|
28
|
+
waiting_bp = bp;
|
29
|
+
}
|
30
|
+
|
31
|
+
function sockio_pager_write(key, value) {
|
32
|
+
throw "sockio_pager does not support write"
|
33
|
+
}
|
34
|
+
|
35
|
+
//Where socket.io data comes in
|
36
|
+
function sockio_pager_sp_endpoint(ep, ename, info) {
|
37
|
+
if (ename === "read_res") {
|
38
|
+
var bp = info.bp;
|
39
|
+
var key = info.key;
|
40
|
+
var value = info.value;
|
41
|
+
int_event(waiting_bp, "read_res", info);
|
42
|
+
vm_cache_write("net", key, value);
|
43
|
+
} else if (ename === "notify") {
|
44
|
+
var key = info.key;
|
45
|
+
vm_notify("net", key);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
function sockio_pager_watch(ns, key) {
|
50
|
+
var info = {
|
51
|
+
ns: ns,
|
52
|
+
key: key
|
53
|
+
}
|
54
|
+
SEND("async", "if_sockio_send", sockio_pager_sp, "watch", info);
|
55
|
+
}
|
56
|
+
|
57
|
+
function sockio_pager_unwatch(ns, key) {
|
58
|
+
var info = {
|
59
|
+
ns: ns,
|
60
|
+
key: key
|
61
|
+
}
|
62
|
+
SEND("async", "if_sockio_send", sockio_pager_sp, "unwatch", info);
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
<% end %>
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<% if @debug %>
|
2
|
+
spec0_data = {};
|
3
|
+
spec0_read_count = 0;
|
4
|
+
|
5
|
+
function spec0_init(options) {
|
6
|
+
spec0_init_options = options;
|
7
|
+
}
|
8
|
+
|
9
|
+
function spec0_read_sync(ns, bp, key) {
|
10
|
+
spec0_read_count += 1;
|
11
|
+
|
12
|
+
var info = {
|
13
|
+
key: key,
|
14
|
+
value: spec0_data[key],
|
15
|
+
}
|
16
|
+
int_event(bp, "read_res", info);
|
17
|
+
//vm_cache[ns][key] = spec0_data[key];
|
18
|
+
}
|
19
|
+
|
20
|
+
function spec0_read(ns, bp, key) {
|
21
|
+
spec0_read_count += 1;
|
22
|
+
|
23
|
+
var info = {
|
24
|
+
key: key,
|
25
|
+
value: spec0_data[key],
|
26
|
+
}
|
27
|
+
|
28
|
+
int_event(bp, "read_res", info);
|
29
|
+
vm_cache_write(ns, key, spec0_data[key]);
|
30
|
+
}
|
31
|
+
|
32
|
+
function spec0_write(key, value) {
|
33
|
+
spec0_data[key] = value;
|
34
|
+
}
|
35
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<% if @debug %>
|
2
|
+
spec1_value = "a";
|
3
|
+
|
4
|
+
function spec1_init(options) {
|
5
|
+
spec1_init_options = options;
|
6
|
+
}
|
7
|
+
|
8
|
+
function spec1_read_sync(ns, bp, key) {
|
9
|
+
throw "unsupported"
|
10
|
+
}
|
11
|
+
|
12
|
+
function spec1_read(ns, bp, key) {
|
13
|
+
var info = {
|
14
|
+
key: key,
|
15
|
+
value: spec1_value,
|
16
|
+
}
|
17
|
+
|
18
|
+
int_event(bp, "read_res", info);
|
19
|
+
vm_cache_write(ns, key, spec1_value);
|
20
|
+
|
21
|
+
//Now change the value
|
22
|
+
spec1_value = "b";
|
23
|
+
}
|
24
|
+
<% end %>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% if @debug %>
|
2
|
+
spec2_value = "a";
|
3
|
+
|
4
|
+
function spec2_init(options) {
|
5
|
+
spec2_init_options = options;
|
6
|
+
}
|
7
|
+
|
8
|
+
function spec2_read_sync(ns, bp, key) {
|
9
|
+
throw "unsupported"
|
10
|
+
}
|
11
|
+
|
12
|
+
function spec2_read(ns, bp, key) {
|
13
|
+
var info = {
|
14
|
+
key: key,
|
15
|
+
value: spec2_value,
|
16
|
+
}
|
17
|
+
|
18
|
+
int_event(bp, "read_res", info);
|
19
|
+
vm_cache_write(ns, key, spec2_value);
|
20
|
+
|
21
|
+
//Now change the value
|
22
|
+
spec2_value = "b";
|
23
|
+
}
|
24
|
+
|
25
|
+
function spec2_watch(ns, key) {
|
26
|
+
}
|
27
|
+
|
28
|
+
function spec2_spec_trigger() {
|
29
|
+
vm_notify("user", "my_key");
|
30
|
+
}
|
31
|
+
<% end %>
|