Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

cmake_minimum_required(VERSION 3.16)
project(robometry LANGUAGES C CXX
VERSION 1.3.0)
VERSION 1.4.0)

include(GNUInstallDirs)
include(FeatureSummary)
Expand Down
6 changes: 6 additions & 0 deletions src/librobometry/include/robometry/BufferManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ class BufferManager {
*/
bool configure(const BufferConfig& _bufferConfig);

/**
* @brief Clear all channels and data from the BufferManager, stopping the periodic save thread.
* After calling this, the BufferManager must be reconfigured before use.
*/
void clear();

/**
* @brief Get the BufferConfig object representing the actual configuration.
*
Expand Down
23 changes: 23 additions & 0 deletions src/librobometry/src/BufferManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,29 @@ bool robometry::BufferManager::configure(const BufferConfig &_bufferConfig) {
return ok;
}

void robometry::BufferManager::clear() {
// Stop the periodic save thread if running
if (m_save_thread.joinable()) {
{
std::unique_lock<std::mutex> lk_cv(m_mutex_cv);
m_should_stop_thread = true;
m_cv.notify_one();
}
m_save_thread.join();
}
m_should_stop_thread = false;

// Reset the tree to clear all channels
m_tree = std::make_shared<TreeNode<BufferInfo>>();

// Clear channel list from config
m_bufferConfig.channels.clear();

// Reset callbacks
m_saveCallback = {};
m_preSaveCallback = {};
}

robometry::BufferConfig robometry::BufferManager::getBufferConfig() const {
return m_bufferConfig;
}
Expand Down
Loading