You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#include"TaskScheduler.h"
enki::TaskScheduler g_TS;
structRunPinnedTaskLoopTask : enki::IPinnedTask
{
voidExecute() override
{
while( g_TS.GetIsRunning() )
{
g_TS.WaitForNewPinnedTasks(); // this thread will 'sleep' until there are new pinned tasks
g_TS.RunPinnedTasks();
}
}
};
structPretendDoFileIO : enki::IPinnedTask
{
voidExecute() override
{
// Do file IO
}
};
intmain(int argc, constchar * argv[])
{
enki::TaskSchedulerConfig config;
// In this example we create more threads than the hardware can run,// because the IO thread will spend most of it's time idle or blocked// and therefore not scheduled for CPU time by the OS
config.numTaskThreadsToCreate += 1;
g_TS.Initialize( config );
// in this example we place our IO threads at the end
RunPinnedTaskLoopTask runPinnedTaskLoopTasks;
runPinnedTaskLoopTasks.threadNum = g_TS.GetNumTaskThreads() - 1;
g_TS.AddPinnedTask( &runPinnedTaskLoopTasks );
// Send pretend file IO task to external thread FILE_IO
PretendDoFileIO pretendDoFileIO;
pretendDoFileIO.threadNum = runPinnedTaskLoopTasks.threadNum;
g_TS.AddPinnedTask( &pretendDoFileIO );
// ensure runPinnedTaskLoopTasks complete by explicitly calling shutdown
g_TS.WaitforAllAndShutdown();
return0;
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Feedback thread for the new WaitForPinnedTasks feature.
Code on dev_WaitForPinnedTasks branch.
Feedback & questions appreciated.
Excerpt from Readme.md:
Beta Was this translation helpful? Give feedback.
All reactions