Some minor fixes/adjustments for coroutines.

This commit is contained in:
Patrick Wuttke 2025-10-28 11:58:30 +01:00
parent 1c7f043e6f
commit 4a3895c0ad

View File

@ -191,10 +191,10 @@ struct TaskReturn<void, TPromise>
}; };
} }
template<typename TValue, template<typename> typename TAllocator = MIJIN_DEFAULT_ALLOCATOR> template<typename TValue = void, template<typename> typename TAllocator = MIJIN_DEFAULT_ALLOCATOR>
using TaskFuture = Future<TValue, TAllocator, MIJIN_COROUTINE_ENABLE_EXCEPTIONS>; using TaskFuture = Future<TValue, TAllocator, MIJIN_COROUTINE_ENABLE_EXCEPTIONS>;
template<typename TValue, template<typename> typename TAllocator = MIJIN_DEFAULT_ALLOCATOR> template<typename TValue = void, template<typename> typename TAllocator = MIJIN_DEFAULT_ALLOCATOR>
using TaskFuturePtr = FuturePtr<TValue, TAllocator, MIJIN_COROUTINE_ENABLE_EXCEPTIONS>; using TaskFuturePtr = FuturePtr<TValue, TAllocator, MIJIN_COROUTINE_ENABLE_EXCEPTIONS>;
template<typename TValue, template<typename> typename TAllocator> template<typename TValue, template<typename> typename TAllocator>
@ -964,7 +964,7 @@ template<typename TResult>
} }
template<template<typename> typename TAllocator> template<template<typename> typename TAllocator>
inline std::suspend_always switchContext(TaskLoop<TAllocator>& taskLoop) inline std::suspend_always c_switchContext(TaskLoop<TAllocator>& taskLoop)
{ {
TaskLoop<TAllocator>& currentTaskLoop = TaskLoop<TAllocator>::current(); TaskLoop<TAllocator>& currentTaskLoop = TaskLoop<TAllocator>::current();
if (&currentTaskLoop == &taskLoop) { if (&currentTaskLoop == &taskLoop) {
@ -974,6 +974,12 @@ inline std::suspend_always switchContext(TaskLoop<TAllocator>& taskLoop)
return {}; return {};
} }
template<template<typename> typename TAllocator>
inline std::suspend_always switchContext(TaskLoop<TAllocator>& taskLoop)
{
return c_switchContext(taskLoop);
}
template<template<typename> typename TAllocator> template<template<typename> typename TAllocator>
void BaseSimpleTaskLoop<TAllocator>::transferCurrentTask(TaskLoop<TAllocator>& otherLoop) MIJIN_NOEXCEPT void BaseSimpleTaskLoop<TAllocator>::transferCurrentTask(TaskLoop<TAllocator>& otherLoop) MIJIN_NOEXCEPT
{ {
@ -1229,7 +1235,7 @@ void BaseMultiThreadedTaskLoop<TAllocator>::workerThread(std::stop_token stopTok
// run it // run it
getCurrentTask() = &*task; getCurrentTask() = &*task;
impl::gCurrentTaskState = task->task->sharedState(); impl::gCurrentTaskState = task->task->sharedState();
tickTask(*task); base_t::tickTask(*task);
getCurrentTask() = nullptr; getCurrentTask() = nullptr;
impl::gCurrentTaskState = nullptr; impl::gCurrentTaskState = nullptr;