mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Cleanup/improve PList usage and Event API
Majority of PLists are now created as automatic/stack objects, rather than on heap and initialized either with the known-capacity reserved upfront or directly from an initializer_list (so there's no wasted slack in the memory that gets allocated for lists containing a fixed/known number of elements). Added versions of the ConnectionEvent/QueueEvent methods that take a val_list by value. Added a move ctor/assign-operator to Plists to allow passing them around without having to copy the underlying array of pointers.
This commit is contained in:
parent
78dcbcc71a
commit
8bc65f09ec
92 changed files with 1585 additions and 1679 deletions
43
src/Event.cc
43
src/Event.cc
|
@ -13,28 +13,27 @@ EventMgr mgr;
|
|||
uint64 num_events_queued = 0;
|
||||
uint64 num_events_dispatched = 0;
|
||||
|
||||
Event::Event(EventHandlerPtr arg_handler, val_list arg_args,
|
||||
SourceID arg_src, analyzer::ID arg_aid, TimerMgr* arg_mgr,
|
||||
BroObj* arg_obj)
|
||||
: handler(arg_handler),
|
||||
args(std::move(arg_args)),
|
||||
src(arg_src),
|
||||
aid(arg_aid),
|
||||
mgr(arg_mgr ? arg_mgr : timer_mgr),
|
||||
obj(arg_obj),
|
||||
next_event(nullptr)
|
||||
{
|
||||
if ( obj )
|
||||
Ref(obj);
|
||||
}
|
||||
|
||||
Event::Event(EventHandlerPtr arg_handler, val_list* arg_args,
|
||||
SourceID arg_src, analyzer::ID arg_aid, TimerMgr* arg_mgr,
|
||||
BroObj* arg_obj)
|
||||
: Event(arg_handler, std::move(*arg_args), arg_src, arg_aid, arg_mgr, arg_obj)
|
||||
{
|
||||
handler = arg_handler;
|
||||
args = arg_args;
|
||||
src = arg_src;
|
||||
mgr = arg_mgr ? arg_mgr : timer_mgr; // default is global
|
||||
aid = arg_aid;
|
||||
obj = arg_obj;
|
||||
|
||||
if ( obj )
|
||||
Ref(obj);
|
||||
|
||||
next_event = 0;
|
||||
}
|
||||
|
||||
Event::~Event()
|
||||
{
|
||||
// We don't Unref() the individual arguments by using delete_vals()
|
||||
// here, because Func::Call already did that.
|
||||
delete args;
|
||||
delete arg_args;
|
||||
}
|
||||
|
||||
void Event::Describe(ODesc* d) const
|
||||
|
@ -49,7 +48,7 @@ void Event::Describe(ODesc* d) const
|
|||
|
||||
if ( ! d->IsBinary() )
|
||||
d->Add("(");
|
||||
describe_vals(args, d);
|
||||
describe_vals(&args, d);
|
||||
if ( ! d->IsBinary() )
|
||||
d->Add("(");
|
||||
}
|
||||
|
@ -62,7 +61,7 @@ void Event::Dispatch(bool no_remote)
|
|||
if ( event_serializer )
|
||||
{
|
||||
SerialInfo info(event_serializer);
|
||||
event_serializer->Serialize(&info, handler->Name(), args);
|
||||
event_serializer->Serialize(&info, handler->Name(), &args);
|
||||
}
|
||||
|
||||
if ( handler->ErrorHandler() )
|
||||
|
@ -70,7 +69,7 @@ void Event::Dispatch(bool no_remote)
|
|||
|
||||
try
|
||||
{
|
||||
handler->Call(args, no_remote);
|
||||
handler->Call(&args, no_remote);
|
||||
}
|
||||
|
||||
catch ( InterpreterException& e )
|
||||
|
@ -129,7 +128,7 @@ void EventMgr::QueueEvent(Event* event)
|
|||
void EventMgr::Drain()
|
||||
{
|
||||
if ( event_queue_flush_point )
|
||||
QueueEvent(event_queue_flush_point, new val_list());
|
||||
QueueEvent(event_queue_flush_point, val_list{});
|
||||
|
||||
SegmentProfiler(segment_logger, "draining-events");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue