Mind:threadMgmt ops: move 0-iter callback to top
This commit is contained in:
+39
-22
@@ -335,7 +335,15 @@ void Mind::joltAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a counter to track when all threads have been jolted
|
||||
// If no threads, set flag and call callback immediately
|
||||
if (componentThreads.size() == 0 && callback)
|
||||
{
|
||||
threadsHaveBeenJolted = true;
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a counter to track when all threads have been jolted
|
||||
auto request = std::make_shared<MindThreadLifetimeMgmtOp>(
|
||||
*this, componentThreads.size(), callback);
|
||||
|
||||
@@ -346,19 +354,19 @@ void Mind::joltAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
&MindThreadLifetimeMgmtOp::joltAllMindThreadsReq1,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
// If no threads, set flag and call callback immediately
|
||||
if (request->loop.nTotalIsZero() && callback)
|
||||
{
|
||||
threadsHaveBeenJolted = true;
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
// Thread management methods (moved from ComponentThread)
|
||||
void Mind::startAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
{
|
||||
// Create a counter to track when all threads have started
|
||||
// If no threads, call callback immediately
|
||||
if (componentThreads.size() == 0 && callback)
|
||||
{
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a counter to track when all threads have started
|
||||
auto request = std::make_shared<MindThreadLifetimeMgmtOp>(
|
||||
*this, componentThreads.size(), callback);
|
||||
|
||||
@@ -369,13 +377,17 @@ void Mind::startAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
&MindThreadLifetimeMgmtOp::executeGenericOpOnAllMindThreadsReq1,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
// If no threads, call callback immediately
|
||||
if (request->loop.nTotalIsZero() && callback) { callback(); }
|
||||
}
|
||||
|
||||
void Mind::pauseAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
{
|
||||
// If no threads, call callback immediately
|
||||
if (componentThreads.size() == 0 && callback)
|
||||
{
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a counter to track when all threads have paused
|
||||
auto request = std::make_shared<MindThreadLifetimeMgmtOp>(
|
||||
*this, componentThreads.size(), callback);
|
||||
@@ -387,14 +399,18 @@ void Mind::pauseAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
&MindThreadLifetimeMgmtOp::executeGenericOpOnAllMindThreadsReq1,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
// If no threads, call callback immediately
|
||||
if (request->loop.nTotalIsZero() && callback) { callback(); }
|
||||
}
|
||||
|
||||
void Mind::resumeAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
{
|
||||
// Create a counter to track when all threads have resumed
|
||||
// If no threads, call callback immediately
|
||||
if (componentThreads.size() == 0 && callback)
|
||||
{
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a counter to track when all threads have resumed
|
||||
auto request = std::make_shared<MindThreadLifetimeMgmtOp>(
|
||||
*this, componentThreads.size(), callback);
|
||||
|
||||
@@ -405,13 +421,17 @@ void Mind::resumeAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
&MindThreadLifetimeMgmtOp::executeGenericOpOnAllMindThreadsReq1,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
// If no threads, call callback immediately
|
||||
if (request->loop.nTotalIsZero() && callback) { callback(); }
|
||||
}
|
||||
|
||||
void Mind::exitAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
{
|
||||
// If no threads, call callback immediately
|
||||
if (componentThreads.size() == 0 && callback)
|
||||
{
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a counter to track when all threads have exited
|
||||
auto request = std::make_shared<MindThreadLifetimeMgmtOp>(
|
||||
*this, componentThreads.size(), callback);
|
||||
@@ -423,9 +443,6 @@ void Mind::exitAllMindThreadsReq(mindThreadLifetimeMgmtOpCbFn callback)
|
||||
&MindThreadLifetimeMgmtOp::executeGenericOpOnAllMindThreadsReq1,
|
||||
request.get(), request));
|
||||
}
|
||||
|
||||
// If no threads, call callback immediately
|
||||
if (request->loop.nTotalIsZero() && callback) { callback(); }
|
||||
}
|
||||
|
||||
} // namespace smo
|
||||
|
||||
Reference in New Issue
Block a user