Make threading and networking optional

This commit is contained in:
2025-02-27 04:17:12 -06:00
parent 29c53b171d
commit 02767f8710
39 changed files with 2054 additions and 99 deletions

View File

@ -8,12 +8,15 @@ namespace Tesses::Framework::Threading
{
#if defined(GEKKO)
return 1;
#else
#elif defined(TESSESFRAMEWORK_ENABLE_THREADING)
return (size_t)std::thread::hardware_concurrency();
#else
return 1;
#endif
}
ThreadPool::ThreadPool(size_t threads)
{
#if defined(TESSESFRAMEWORK_ENABLE_THREADING)
this->isRunning=true;
for(size_t i = 0; i < threads; i++)
{
@ -41,15 +44,19 @@ namespace Tesses::Framework::Threading
}
}));
}
#endif
}
void ThreadPool::Schedule(std::function<void()> cb)
{
#if defined(TESSESFRAMEWORK_ENABLE_THREADING)
this->mtx.Lock();
this->callbacks.push(cb);
this->mtx.Unlock();
#endif
}
ThreadPool::~ThreadPool()
{
#if defined(TESSESFRAMEWORK_ENABLE_THREADING)
while(true)
{
this->mtx.Lock();
@ -64,6 +71,6 @@ namespace Tesses::Framework::Threading
item->Join();
delete item;
}
#endif
}
}