1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// $Id$
#include "Notify_Event_Processor.h"
#include "Notify_Worker_Task.h"
#include "Notify_Source_Filter_Eval_Command.h"
#include "Notify_Listener_Filter_Eval_Command.h"
#include "Notify_Event_Manager_Objects_Factory.h"
#include "Notify_Lookup_Command.h"
#include "Notify_Event_Dispatch_Command.h"
#include "Notify_Factory.h"
#include "Notify_Listeners.h"
#include "Notify_Event_Manager.h"
ACE_RCSID(Notify, Notify_Event_Processor, "$Id$")
TAO_Notify_Event_Processor::TAO_Notify_Event_Processor (TAO_Notify_Event_Manager* event_manager)
:event_manager_ (event_manager),
lookup_task_ (0),
emo_factory_ (0)
{
this->emo_factory_ = event_manager_->resource_factory ();
}
TAO_Notify_Event_Processor::~TAO_Notify_Event_Processor ()
{
delete this->lookup_task_;
}
void
TAO_Notify_Event_Processor::init (CORBA::Environment& ACE_TRY_ENV)
{
this->lookup_task_ = this->emo_factory_->create_lookup_task (ACE_TRY_ENV);
ACE_CHECK;
// Get hold of the admin properties.
TAO_Notify_AdminProperties* const admin_properties =
this->event_manager_->admin_properties ();
this->lookup_task_->init_task (admin_properties);
}
void
TAO_Notify_Event_Processor::shutdown (CORBA::Environment & ACE_TRY_ENV)
{
this->lookup_task_->shutdown (ACE_TRY_ENV);
}
void
TAO_Notify_Event_Processor::evaluate_source_filter (TAO_Notify_Event* event,
TAO_Notify_EventSource* event_source,
CORBA::Environment& ACE_TRY_ENV)
{
// TODO: use cache allocator here.
// @@ Pradeep: you shouldn't be allocating at all! If this must go
// into a queue then the processing queue should make the
// allocation, that way the single threaded case works just fine.
TAO_Notify_Source_Filter_Eval_Command* mb =
new TAO_Notify_Source_Filter_Eval_Command (this, event, event_source);
event_source->filter_eval_task ()->process_event (mb, ACE_TRY_ENV);
}
void
TAO_Notify_Event_Processor::lookup_subscriptions (TAO_Notify_Event* event,
TAO_Notify_EventSource* /*event_source*/,
CORBA::Environment &ACE_TRY_ENV)
{
TAO_Notify_Lookup_Command* lookup =
new TAO_Notify_Lookup_Command (this, event, this->event_manager_->event_map ());
this->lookup_task_->process_event (lookup, ACE_TRY_ENV);
}
void
TAO_Notify_Event_Processor::evaluate_listener_filter (TAO_Notify_Event* event, TAO_Notify_EventListener* event_listener, CORBA::Boolean eval_parent, CORBA::Environment &ACE_TRY_ENV)
{
// @@ Pradeep: you should use ACE_NEW here....
// @@ Pradeep: do you really need to allocate this guy from the
// heap? Maybe you can just allocate it from the stack and only if
// somebody really wants to keep it around you make a copy? The
// idea is to save allocations in the good case.
TAO_Notify_Listener_Filter_Eval_Command* mb =
new TAO_Notify_Listener_Filter_Eval_Command (this, event, event_listener, eval_parent);
event_listener->filter_eval_task ()->process_event (mb, ACE_TRY_ENV);
}
void
TAO_Notify_Event_Processor::dispatch_event (TAO_Notify_Event* event, TAO_Notify_EventListener* event_listener, CORBA::Environment &ACE_TRY_ENV)
{
TAO_Notify_Event_Dispatch_Command* dispatch =
new TAO_Notify_Event_Dispatch_Command (this, event, event_listener);
event_listener->event_dispatch_task ()->process_event (dispatch, ACE_TRY_ENV);
}
|