MCPcopy Create free account
hub / github.com/christophhart/HISE / addJob

Method addJob

hi_scripting/scripting/ScriptProcessor.cpp:2457–2542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2455{ return isSleeping; }
2456
2457void JavascriptThreadPool::addJob(Task::Type t, JavascriptProcessor* p, const Task::Function& f)
2458{
2459 WARN_IF_AUDIO_THREAD(true, IllegalAudioThreadOps::StringCreation);
2460
2461 auto currentThread = getMainController()->getKillStateHandler().getCurrentThread();
2462
2463 if (t != Task::Type::Compilation && isSleeping)
2464 return;
2465
2466 switch (currentThread)
2467 {
2468 case MainController::KillStateHandler::TargetThread::SampleLoadingThread:
2469 {
2470 jassert(!getMainController()->getKillStateHandler().isAudioRunning());
2471
2472 if (t == Task::Type::LowPriorityCallbackExecution)
2473 {
2474 pushToQueue(t, p, f);
2475 }
2476 else
2477 {
2478
2479 // We're calling a high-priority task from the sample loading thread.
2480 // This can be executed synchronously
2481
2482 Result r = executeNow(t, p, f);
2483
2484 if (r.failed())
2485 getMainController()->getConsoleHandler().writeToConsole(r.getErrorMessage(), 1, dynamic_cast<Processor*>(p), Colours::blue);
2486 }
2487
2488 break;
2489 }
2490 case MainController::KillStateHandler::TargetThread::ScriptingThread:
2491 {
2492 jassert(isBusy());
2493
2494 if (t == currentType)
2495 {
2496 // Same priority, just run it
2497 executeNow(t, p, f);
2498 }
2499 else
2500 {
2501 if (t == Task::Type::LowPriorityCallbackExecution)
2502 {
2503 // We're calling a low priority task from a high priority task
2504 // In this case, we defer the task to later (it's just a timer
2505 // callback or a repaint function).
2506 pushToQueue(t, p, f);
2507 }
2508 else
2509 {
2510 // We're calling a high priority task from a low priority
2511 // callback, so we need to execute it synchronously.
2512 executeNow(t, p, f);
2513 }
2514 }

Callers 2

handleAsyncUpdateMethod · 0.45
controlCallbackMethod · 0.45

Calls 7

getCurrentThreadMethod · 0.45
isAudioRunningMethod · 0.45
failedMethod · 0.45
writeToConsoleMethod · 0.45
getErrorMessageMethod · 0.45
isInitialisedMethod · 0.45

Tested by

no test coverage detected