CAM fix nested traces and new async slicer call. added async worker support
This commit is contained in:
parent
4c78afb8dd
commit
57f77d459b
7 changed files with 47 additions and 20 deletions
|
|
@ -647,11 +647,15 @@ kiri.worker = {
|
|||
}
|
||||
};
|
||||
|
||||
function is_async(fn) {
|
||||
return fn.constructor.name === "AsyncFunction";
|
||||
}
|
||||
|
||||
dispatch.send = (msg, direct) => {
|
||||
self.postMessage(msg, direct);
|
||||
};
|
||||
|
||||
dispatch.onmessage = self.onmessage = function(e) {
|
||||
dispatch.onmessage = self.onmessage = async function(e) {
|
||||
let time_recv = time(),
|
||||
msg = e.data || {},
|
||||
run = dispatch[msg.task],
|
||||
|
|
@ -683,7 +687,7 @@ dispatch.onmessage = self.onmessage = function(e) {
|
|||
if (run) {
|
||||
try {
|
||||
let time_xfer = (time_recv - msg.time),
|
||||
output = run(msg.data, send),
|
||||
output = is_async(run) ? await run(msg.data, send) : run(msg.data, send),
|
||||
time_send = time(),
|
||||
time_proc = time_send - time_recv;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue