[+] Added AuIsThreadRunning
[*] Fix path bug [*] Fixed two async shutdown bug
This commit is contained in:
parent
d28a4576ba
commit
6135618e24
@ -59,8 +59,9 @@ namespace Aurora::Async
|
||||
|
||||
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerId_tt, WorkerId_t>)>
|
||||
static AuSPtr<IWorkItem> NewWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false)
|
||||
{
|
||||
return NewWorkItem(worker, AuMakeShared<WorkPairImpl<Info_t, Result_t, Task_t>>(task, job), enableWait);
|
||||
{
|
||||
auto baa = AuMakeShared<WorkPairImpl<Info_t, Result_t, Task_t>>(task, job);
|
||||
return NewWorkItem(worker, baa, enableWait);
|
||||
}
|
||||
|
||||
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v<WorkerId_tt, WorkerId_t>)>
|
||||
|
@ -102,6 +102,11 @@ namespace AuMemory = Aurora::Memory;
|
||||
using AuWorkerId_t = AuAsync::WorkerId_t;
|
||||
using AuWorkerPId_t = AuAsync::WorkerPId_t;
|
||||
|
||||
static bool AuIsThreadRunning()
|
||||
{
|
||||
return !AuThreads::GetThread()->Exiting();
|
||||
}
|
||||
|
||||
static inline void AuDebugBreak()
|
||||
{
|
||||
AuDebug::DebugBreak();
|
||||
|
@ -323,6 +323,12 @@ namespace Aurora::Async
|
||||
break;
|
||||
}
|
||||
|
||||
// pre-wakeup thread terminating check
|
||||
if (state->threadObject->Exiting() || state->shuttingdown)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Block if no work items are present
|
||||
if (state->pendingWorkItems.empty())
|
||||
{
|
||||
@ -571,7 +577,11 @@ namespace Aurora::Async
|
||||
{
|
||||
for (auto &[id, worker] : group->workers)
|
||||
{
|
||||
worker->shuttingdown = true;
|
||||
{
|
||||
AU_LOCK_GUARD(group->cvWorkMutex);
|
||||
worker->shuttingdown = true;
|
||||
group->cvVariable->Broadcast();
|
||||
}
|
||||
|
||||
if (groupId != 0)
|
||||
{
|
||||
@ -585,12 +595,6 @@ namespace Aurora::Async
|
||||
event->Set();
|
||||
}
|
||||
}
|
||||
|
||||
if (group->cvVariable)
|
||||
{
|
||||
AU_LOCK_GUARD(group->cvWorkMutex);
|
||||
group->cvVariable->Broadcast();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ namespace Aurora::Async
|
||||
|
||||
void WorkItem::CancelAsync()
|
||||
{
|
||||
AU_LOCK_GUARD(this->lock);
|
||||
AU_TRY_LOCK_GUARD_NAMED(this->lock, asd);
|
||||
Fail();
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ namespace Aurora::Console::Commands
|
||||
}
|
||||
}
|
||||
|
||||
gCommandDispatcher = Async::WorkerPId_t(AuUnsafeRaiiToShared(AuAsync::GetAsyncApp()), target.value());
|
||||
gCommandDispatcher = Async::WorkerPId_t(AuUnsafeRaiiToShared(AuAsync::GetAsyncApp()), target.value_or(AuAsync::ThreadGroup_t {}));
|
||||
}
|
||||
|
||||
static void DispatchCommandsFromThis(const AuList<CommandDispatch> &commands)
|
||||
|
@ -59,10 +59,11 @@ namespace Aurora::IO::FS
|
||||
{
|
||||
for (int i = 0; i < cpath.size(); i++)
|
||||
{
|
||||
bool end = i == cpath.size() - 1;
|
||||
if ((cpath[i] == kPathSplitter) ||
|
||||
((!isFile) && (i == cpath.size() - 1)))
|
||||
((!isFile) && (end)))
|
||||
{
|
||||
auto subpath = AuString(cpath.begin(), cpath.begin() + i);
|
||||
auto subpath = end ? cpath : AuString(cpath.begin(), cpath.begin() + i);
|
||||
|
||||
if (DirExists(subpath))
|
||||
{
|
||||
|
@ -383,7 +383,7 @@ namespace Aurora::IO::FS
|
||||
|
||||
// Try to modify the object's DACL.
|
||||
dwRes = SetNamedSecurityInfoW(
|
||||
Locale::ConvertFromUTF8(path).data(), // name of the object
|
||||
Locale::ConvertFromUTF8(FS::NormalizePathRet(path)).data(), // name of the object
|
||||
SE_FILE_OBJECT, // type of object
|
||||
DACL_SECURITY_INFORMATION, // change only the object's DACL
|
||||
NULL, NULL, // do not change owner or group
|
||||
|
@ -27,7 +27,7 @@ namespace Aurora::Processes
|
||||
{
|
||||
AU_LOCK_GUARD(gCondMutex);
|
||||
|
||||
while (!gOpenerThread->Exiting())
|
||||
while (AuIsThreadRunning())
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -344,6 +344,11 @@ namespace Aurora::Registry
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!lastPath_.value().size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IO::FS::WriteString(lastPath_.value(), currentStreamDocument_.dump(4)))
|
||||
{
|
||||
SysPushErrorIO("Couldn't write registry to {}", lastPath_.value());
|
||||
|
Loading…
Reference in New Issue
Block a user