notes. tweaks for future command line usage. bump rev 2.9.D9
This commit is contained in:
parent
c4a6f3d989
commit
3507f67b73
7 changed files with 42 additions and 32 deletions
|
|
@ -32,15 +32,16 @@ function send(fn, data, onreply, zerocopy) {
|
|||
// track it only when we expect and can handle a reply
|
||||
running[seq] = { fn:onreply };
|
||||
}
|
||||
// console.log('send', {fn, data, onreply});
|
||||
|
||||
let msg = {
|
||||
seq: seq,
|
||||
task: fn,
|
||||
time: time(),
|
||||
data: data
|
||||
};
|
||||
// console.log('client send', msg);
|
||||
// if (!fn) { console.trace({empty_fn: data}) };
|
||||
try {
|
||||
worker.postMessage({
|
||||
seq: seq,
|
||||
task: fn,
|
||||
time: time(),
|
||||
data: data
|
||||
}, zerocopy);
|
||||
worker.postMessage(msg, zerocopy);
|
||||
} catch (error) {
|
||||
console.trace('work send error', {data, error});
|
||||
}
|
||||
|
|
@ -92,13 +93,13 @@ KIRI.work = {
|
|||
running = {};
|
||||
worker = KIRI.work.newWorker();
|
||||
|
||||
worker.onmessage = function(e) {
|
||||
CLIENT.onmessage = worker.onmessage = function(e) {
|
||||
let now = time(),
|
||||
reply = e.data,
|
||||
record = running[reply.seq],
|
||||
onreply = record ? record.fn : undefined;
|
||||
|
||||
// console.log('recv', reply.data)
|
||||
// console.log('client recv', e)
|
||||
if (reply.done) {
|
||||
delete running[reply.seq];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -633,6 +633,12 @@
|
|||
return 0;
|
||||
};
|
||||
|
||||
// allow worker code to run in same memspace as client
|
||||
PRO.setInWorker = function() {
|
||||
this.inWorker = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* processes points into facets, then into slices
|
||||
*
|
||||
|
|
@ -654,7 +660,7 @@
|
|||
widget.clearSlices();
|
||||
onupdate(0.0001, "slicing");
|
||||
|
||||
if (KIRI.client) {
|
||||
if (KIRI.client && !widget.inWorker) {
|
||||
// in case result of slice is nothing, do not preserve previous
|
||||
widget.slices = []
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ KIRI.worker = {
|
|||
wgroup[data.group] = group;
|
||||
}
|
||||
let vertices = new Float32Array(data.vertices),
|
||||
widget = KIRI.newWidget(data.id, group).loadVertices(vertices);
|
||||
widget = KIRI.newWidget(data.id, group).loadVertices(vertices).setInWorker();
|
||||
|
||||
// do it here so cancel can work
|
||||
wcache[data.id] = widget;
|
||||
|
|
@ -560,9 +560,15 @@ KIRI.worker = {
|
|||
}
|
||||
};
|
||||
|
||||
self.onmessage = function(e) {
|
||||
dispatch.send = (msg) => {
|
||||
// console.log('worker send', msg);
|
||||
self.postMessage(msg);
|
||||
};
|
||||
|
||||
dispatch.onmessage = self.onmessage = function(e) {
|
||||
// console.log('worker recv', e);
|
||||
let time_recv = time(),
|
||||
msg = e.data,
|
||||
msg = e.data || {},
|
||||
run = dispatch[msg.task],
|
||||
send = {
|
||||
data : function(data,direct) {
|
||||
|
|
@ -572,7 +578,7 @@ self.onmessage = function(e) {
|
|||
// sz:direct.map(z => z.byteLength).reduce((a,v) => a+v)
|
||||
// });
|
||||
// }
|
||||
self.postMessage({
|
||||
dispatch.send({
|
||||
seq: msg.seq,
|
||||
task: msg.task,
|
||||
done: false,
|
||||
|
|
@ -586,7 +592,7 @@ self.onmessage = function(e) {
|
|||
// sz:direct.map(z => z.byteLength).reduce((a,v) => a+v)
|
||||
// });
|
||||
// }
|
||||
self.postMessage({
|
||||
dispatch.send({
|
||||
seq: msg.seq,
|
||||
task: msg.task,
|
||||
done: true,
|
||||
|
|
@ -602,7 +608,7 @@ self.onmessage = function(e) {
|
|||
time_send = time(),
|
||||
time_proc = time_send - time_recv;
|
||||
|
||||
if (output) self.postMessage({
|
||||
if (output) dispatch.send({
|
||||
seq: msg.seq,
|
||||
task: msg.task,
|
||||
time_send: time_xfer,
|
||||
|
|
@ -617,7 +623,7 @@ self.onmessage = function(e) {
|
|||
send.done({error: wrkerr.toString()});
|
||||
}
|
||||
} else {
|
||||
console.log({kiri_msg:e});
|
||||
console.log({worker_unhandled: e, msg, fn: dispatch[msg.task]});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue