Background execution of terminal scripts
-
@Christoph-Hart I'm creating the background task into a local variable in an inline function. Does the naming of the task matter? Can two of these run at the same time with the same name?
-
I'm creating the background task into a local variable in an inline function.
That will blow up in your face. Can't you define a background thread in the onInit? It sits around idle until you call
callOnBackgroundThread()
, but if it's a local variable then you'll get into lots of possible issues with the lifetime (it being destroyed while the thread is still active). -
@Christoph-Hart oh... it seems to be working fine at the moment, however i'm not referring to the locals inside the runProcess function, I'm just using them to create temporary background processes.
what do you mean by "define a background thread"?
-
@aaronventure I think he means this - https://docs.hise.audio/scripting/scripting-api/backgroundtask/index.html
-
@d-healey ah so just define it into const instead of a temporary local variable? I see now that's how the docs do it
-
@Christoph-Hart said in Background execution of terminal scripts:
That will blow up in your face.
Ah I get it now. It does result in another crash, though
-
@aaronventure can you reliably reproduce this with a snippet? That looks like you‘re deleting a object on one thread while using it on another.
-
@Christoph-Hart no, not really, because the function executed first and then it crashed one second later.
I was creating the task inside the inline function in a local variable. As soon as I moved the createBackgorundTask call outside of the function and directly in on i it, crashing stopped. So, probably that was the object?
-
@Christoph-Hart could
! ! killing thread by force !!
also tell me which thread is it killing? Like the task name that we give it upon creation? -
@aaronventure you can easily do this as local change to find out what's happening:
Just search for the string in the HISE codebase and replace the line with
Logger::writeToLog ("!! killing thread by force !!" + getThreadName());