Skip to content

Commit

Permalink
CallbackThread renamed to CCallbackThread (all classes shall start wi…
Browse files Browse the repository at this point in the history
…th a 'C' :-)).
  • Loading branch information
rex-schilasky committed Nov 30, 2023
1 parent e0a969e commit f0061ca
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ecal/core/src/io/udp/rcv_logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace eCAL
m_msg_buffer.resize(MSG_BUFFER_SIZE);

// start receiver thread
m_udp_receiver_thread = std::make_shared<CallbackThread>(std::bind(&CUDPLoggingReceiver::ReceiveThread, this));
m_udp_receiver_thread = std::make_shared<CCallbackThread>(std::bind(&CUDPLoggingReceiver::ReceiveThread, this));
m_udp_receiver_thread->start(std::chrono::milliseconds(0));
}

Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/io/udp/rcv_logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace eCAL
LogMessageCallbackT m_log_message_callback;

CUDPReceiver m_udp_receiver;
std::shared_ptr<CallbackThread> m_udp_receiver_thread;
std::shared_ptr<CCallbackThread> m_udp_receiver_thread;

std::vector<char> m_msg_buffer;
eCAL::pb::LogMessage m_log_message;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/io/udp/rcv_sample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ CUDPSampleReceiver::CUDPSampleReceiver(const eCAL::SReceiverAttr& attr_, HasSamp
m_msg_buffer.resize(MSG_BUFFER_SIZE);

// start receiver thread
m_udp_receiver_thread = std::make_shared<eCAL::CallbackThread>(std::bind(&CUDPSampleReceiver::ReceiveThread, this));
m_udp_receiver_thread = std::make_shared<eCAL::CCallbackThread>(std::bind(&CUDPSampleReceiver::ReceiveThread, this));
m_udp_receiver_thread->start(std::chrono::milliseconds(0));

m_cleanup_start = std::chrono::steady_clock::now();
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/io/udp/rcv_sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CUDPSampleReceiver
ApplySampleCallbackT m_apply_sample_callback;

eCAL::CUDPReceiver m_udp_receiver;
std::shared_ptr<eCAL::CallbackThread> m_udp_receiver_thread;
std::shared_ptr<eCAL::CCallbackThread> m_udp_receiver_thread;

using ReceiveSlotMapT = std::unordered_map<int32_t, std::shared_ptr<CSampleReceiveSlot>>;
ReceiveSlotMapT m_receive_slot_map;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/pubsub/ecal_subgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace eCAL
CDataReader::InitializeLayers();

// start timeout thread
m_subtimeout_thread = std::make_shared<CallbackThread>(std::bind(&CSubGate::CheckTimeouts, this));
m_subtimeout_thread = std::make_shared<CCallbackThread>(std::bind(&CSubGate::CheckTimeouts, this));
m_subtimeout_thread->start(std::chrono::milliseconds(CMN_DATAREADER_TIMEOUT_RESOLUTION_MS));

m_created = true;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/pubsub/ecal_subgate.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ namespace eCAL
std::shared_timed_mutex m_topic_name_datareader_sync;
TopicNameDataReaderMapT m_topic_name_datareader_map;

std::shared_ptr<CallbackThread> m_subtimeout_thread;
std::shared_ptr<CCallbackThread> m_subtimeout_thread;
};
}
2 changes: 1 addition & 1 deletion ecal/core/src/registration/ecal_registration_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ namespace eCAL
}

// start cyclic registration thread
m_reg_sample_snd_thread = std::make_shared<CallbackThread>(std::bind(&CRegistrationProvider::RegisterSendThread, this));
m_reg_sample_snd_thread = std::make_shared<CCallbackThread>(std::bind(&CRegistrationProvider::RegisterSendThread, this));
m_reg_sample_snd_thread->start(std::chrono::milliseconds(Config::GetRegistrationRefreshMs()));

m_created = true;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/registration/ecal_registration_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace eCAL
bool m_reg_process;

std::shared_ptr<CSampleSender> m_reg_sample_snd;
std::shared_ptr<CallbackThread> m_reg_sample_snd_thread;
std::shared_ptr<CCallbackThread> m_reg_sample_snd_thread;

using SampleMapT = std::unordered_map<std::string, eCAL::pb::Sample>;
std::mutex m_topics_map_sync;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/registration/ecal_registration_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace eCAL

// start memfile broadcast receive thread
m_memfile_broadcast_reader = memfile_broadcast_reader_;
m_memfile_broadcast_reader_thread = std::make_shared<CallbackThread>(std::bind(&CMemfileRegistrationReceiver::Receive, this));
m_memfile_broadcast_reader_thread = std::make_shared<CCallbackThread>(std::bind(&CMemfileRegistrationReceiver::Receive, this));
m_memfile_broadcast_reader_thread->start(std::chrono::milliseconds(Config::GetRegistrationRefreshMs()/2));

m_created = true;
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/registration/ecal_registration_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace eCAL
void Receive();

CMemoryFileBroadcastReader* m_memfile_broadcast_reader = nullptr;
std::shared_ptr<CallbackThread> m_memfile_broadcast_reader_thread;
std::shared_ptr<CCallbackThread> m_memfile_broadcast_reader_thread;

bool m_created = false;
};
Expand Down
13 changes: 7 additions & 6 deletions ecal/core/src/util/ecal_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ namespace eCAL
/**
* @brief A class that encapsulates threaded functionality with a callback interface.
*/
class CallbackThread {
class CCallbackThread
{
public:
/**
* @brief Constructor for the CallbackThread class.
* @param callback A callback function to be executed in the CallbackThread thread.
*/
CallbackThread(std::function<void()> callback)
: callback_(callback), stopThread_(false) {}
CCallbackThread(std::function<void()> callback)
: callback_(callback) {}

/**
* @brief Start the callback thread with a specified timeout.
Expand All @@ -50,7 +51,7 @@ namespace eCAL
template <typename DurationType>
void start(DurationType timeout)
{
callbackThread_ = std::thread(&CallbackThread::callbackFunction<DurationType>, this, timeout);
callbackThread_ = std::thread(&CCallbackThread::callbackFunction<DurationType>, this, timeout);
}

/**
Expand All @@ -60,7 +61,7 @@ namespace eCAL
void stop()
{
{
std::unique_lock<std::mutex> lock(mtx_);
const std::unique_lock<std::mutex> lock(mtx_);
// Set the flag to signal the callback thread to stop
stopThread_ = true;
// Notify the callback thread to wake up and check the flag
Expand All @@ -78,7 +79,7 @@ namespace eCAL
std::function<void()> callback_; /**< The callback function to be executed in the callback thread. */
std::mutex mtx_; /**< Mutex for thread synchronization. */
std::condition_variable cv_; /**< Condition variable for signaling between threads. */
bool stopThread_; /**< Flag to indicate whether the callback thread should stop. */
bool stopThread_{false}; /**< Flag to indicate whether the callback thread should stop. */

/**
* @brief Callback function that runs in the callback thread.
Expand Down

0 comments on commit f0061ca

Please sign in to comment.