Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
CastagnaIT committed Aug 25, 2023
1 parent bae2955 commit 7d6e853
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/common/AdaptiveTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,11 @@ namespace adaptive
{
std::unique_lock<std::mutex> updLck(m_updMutex);

while (~m_tree->m_updateInterval && !m_threadStop)
while (~m_tree->m_updateInterval)
{
if (m_threadStop)
break;

if (m_cvUpdInterval.wait_for(updLck, std::chrono::milliseconds(m_tree->m_updateInterval)) ==
std::cv_status::timeout)
{
Expand All @@ -579,6 +582,18 @@ namespace adaptive
}
}

void AdaptiveTree::TreeUpdateThread::Stop()
{
// If an update is already in progress the wait until its finished
while (true)
{
std::lock_guard<std::mutex> updLck{m_updMutex};
if (m_waitQueue == 0)
break;
}
m_threadStop = true;
}

void AdaptiveTree::TreeUpdateThread::Pause()
{
// If an update is already in progress the wait until its finished
Expand Down
5 changes: 5 additions & 0 deletions src/common/AdaptiveTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,8 @@ class ATTR_DLL_LOCAL AdaptiveTree
AdaptiveTree(const AdaptiveTree& left);
virtual ~AdaptiveTree()
{
m_updThread.Stop();

for (auto period : periods_)
delete period;
}
Expand Down Expand Up @@ -639,6 +641,9 @@ class ATTR_DLL_LOCAL AdaptiveTree
// \brief As "std::mutex" unlock, but resume the manifest updates (support std::lock_guard).
void unlock() { Resume(); }

// \brief Stop performing new updates.
void Stop()

private:
void Worker();
void Pause();
Expand Down

0 comments on commit 7d6e853

Please sign in to comment.