multithreading - How to reset a multithreaded task? (JXcore) -


i have node.js application i've moved jxcore multithreading , yet couldn't figure out how reset task. on current implementation, server creates sub process , send jobs 1 one.

when job takes more x seconds, main process kills sub process , skips running task , logs it. of jobs shouldn't take more x seconds.

so far, moved queue system jxcore , works expected couldn't figure out yet, how can kill running task.

looks ability kill running task needed feature, since asked same question , has been answered here: thread lifetime management.

upcoming jxcore release have jxcore.tasks.killthread(). logic this: task inform main thread, has been started, , main thread may start counting timeout killing thread, example:

// main thread receives message task jxcore.tasks.on("message", function(threadid, obj){     if(obj.started){         //kill task after second         settimeout(function(){             jxcore.tasks.killthread(threadid);             console.log("thread killed", threadid);         },1000);     } });  // adding task jxcore.tasks.addtask( function() {     // informing main thread, task started     process.sendtomain({started:true});      // looping forever     while(true){};     console.log("this line never happen."); });  

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -