Move threading classes to zeek namespaces

This commit is contained in:
Tim Wojtulewicz 2020-08-01 10:48:46 -07:00
parent f310795d79
commit 1262109e5a
42 changed files with 299 additions and 210 deletions

View file

@ -8,9 +8,11 @@
#include "Manager.h"
#include "iosource/Manager.h"
using namespace threading;
// Set by Zeek's main signal handler.
extern int signal_val;
namespace threading {
namespace zeek::threading {
namespace detail {
////// Messages.
@ -124,8 +126,6 @@ private:
};
#endif
}
// An event that the child wants to pass into the main event queue
class SendEventMessage final : public OutputMessage<MsgThread> {
public:
@ -151,13 +151,6 @@ private:
Value* *val;
};
////// Methods.
Message::~Message()
{
delete [] name;
}
bool ReporterMessage::Process()
{
switch ( type ) {
@ -197,6 +190,15 @@ bool ReporterMessage::Process()
return true;
}
} // namespace detail
////// Methods.
Message::~Message()
{
delete [] name;
}
MsgThread::MsgThread() : BasicThread(), queue_in(this, nullptr), queue_out(nullptr, this)
{
cnt_sent_in = cnt_sent_out = 0;
@ -219,9 +221,6 @@ MsgThread::~MsgThread()
zeek::iosource_mgr->UnregisterFd(flare.FD(), this);
}
// Set by Bro's main signal handler.
extern int signal_val;
void MsgThread::OnSignalStop()
{
if ( main_finished || Killed() || child_sent_finish )
@ -229,7 +228,7 @@ void MsgThread::OnSignalStop()
child_sent_finish = true;
// Signal thread to terminate.
SendIn(new FinishMessage(this, network_time), true);
SendIn(new detail::FinishMessage(this, network_time), true);
}
void MsgThread::OnWaitForStop()
@ -303,43 +302,43 @@ void MsgThread::Heartbeat()
if ( child_sent_finish )
return;
SendIn(new HeartbeatMessage(this, network_time, current_time()));
SendIn(new detail::HeartbeatMessage(this, network_time, current_time()));
}
void MsgThread::Finished()
{
child_finished = true;
SendOut(new FinishedMessage(this));
SendOut(new detail::FinishedMessage(this));
}
void MsgThread::Info(const char* msg)
{
SendOut(new ReporterMessage(ReporterMessage::INFO, this, msg));
SendOut(new detail::ReporterMessage(detail::ReporterMessage::INFO, this, msg));
}
void MsgThread::Warning(const char* msg)
{
SendOut(new ReporterMessage(ReporterMessage::WARNING, this, msg));
SendOut(new detail::ReporterMessage(detail::ReporterMessage::WARNING, this, msg));
}
void MsgThread::Error(const char* msg)
{
SendOut(new ReporterMessage(ReporterMessage::ERROR, this, msg));
SendOut(new detail::ReporterMessage(detail::ReporterMessage::ERROR, this, msg));
}
void MsgThread::FatalError(const char* msg)
{
SendOut(new ReporterMessage(ReporterMessage::FATAL_ERROR, this, msg));
SendOut(new detail::ReporterMessage(detail::ReporterMessage::FATAL_ERROR, this, msg));
}
void MsgThread::FatalErrorWithCore(const char* msg)
{
SendOut(new ReporterMessage(ReporterMessage::FATAL_ERROR_WITH_CORE, this, msg));
SendOut(new detail::ReporterMessage(detail::ReporterMessage::FATAL_ERROR_WITH_CORE, this, msg));
}
void MsgThread::InternalWarning(const char* msg)
{
SendOut(new ReporterMessage(ReporterMessage::INTERNAL_WARNING, this, msg));
SendOut(new detail::ReporterMessage(detail::ReporterMessage::INTERNAL_WARNING, this, msg));
}
void MsgThread::InternalError(const char* msg)
@ -353,7 +352,7 @@ void MsgThread::InternalError(const char* msg)
void MsgThread::Debug(zeek::DebugStream stream, const char* msg)
{
SendOut(new DebugMessage(stream, this, msg));
SendOut(new detail::DebugMessage(stream, this, msg));
}
#endif
@ -390,7 +389,7 @@ void MsgThread::SendOut(BasicOutputMessage* msg, bool force)
void MsgThread::SendEvent(const char* name, const int num_vals, Value* *vals)
{
SendOut(new SendEventMessage(this, name, num_vals, vals));
SendOut(new detail::SendEventMessage(this, name, num_vals, vals));
}
BasicOutputMessage* MsgThread::RetrieveOut()
@ -440,7 +439,7 @@ void MsgThread::Run()
// after all other outgoing messages (in particular
// error messages have been processed by then main
// thread).
SendOut(new KillMeMessage(this));
SendOut(new detail::KillMeMessage(this));
failed = true;
}
}
@ -483,3 +482,5 @@ void MsgThread::Process()
delete msg;
}
}
} // namespace zeek::threading