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
97
98
99
100
101
102
103
104
105
106
107
|
//
// $Id$
//
#include "ace/High_Res_Timer.h"
#include "Scheduler_Factory.h"
#include "ReactorTask.h"
ACE_ES_Reactor_Task::ACE_ES_Reactor_Task() :
// reactor_ (0, &timer_queue_),
done_ (0)
{
// Change the timer mechanism used by the reactor and the timer
// queue.
#if defined (VXWORKS)
timer_queue_.gettimeofday (ACE_OS::gettimeofday);
#else
timer_queue_.gettimeofday (ACE_High_Res_Timer::gettimeofday);
#endif /* VXWORKS */
}
ACE_ES_Reactor_Task::~ACE_ES_Reactor_Task (void)
{
}
int
ACE_ES_Reactor_Task::svc_hook(RtecScheduler::OS_Priority)
{
// Make ourselves owner of the reactor.
reactor_.owner (ACE_Thread::self());
return 0;
}
int
ACE_ES_Reactor_Task::open_reactor (RtecScheduler::Period &period)
{
// Create a name for ourself using the priority.
char temp[64];
ACE_OS::sprintf (temp, "Reactor_Task-%u", period);
// Open the task. This will query the scheduler for our qos
// structure.
int result = this->open_task (temp);
switch (result)
{
case -1:
// Error.
ACE_ERROR ((LM_ERROR, "(%t) Scheduler could not find operation %s.\n",
temp));
return -1;
case 0:
// @@ TODO handle exceptions
{
ACE_TRY
{
ACE_Scheduler_Factory::server()->set(rt_info_,
0, 0, 0, period,
RtecScheduler::VERY_LOW,
RtecScheduler::NO_QUANTUM,
1, ACE_TRY_ENV);
ACE_CHECK_ENV;
}
ACE_CATCHANY
{
ACE_ERROR_RETURN ((LM_ERROR, "set failed\n"), -1);
}
ACE_ENDTRY;
}
break;
case 1:
// Found.
break;
}
return this->synch_threads (1);
}
int ACE_ES_Reactor_Task::svc_one()
{
if (reactor_.handle_events() == -1)
ACE_ERROR ((LM_ERROR, "(%t) %p.\n", "ACE_ES_Reactor_Task::svc"));
if (done_)
ACE_DEBUG ((LM_DEBUG, "(%t) Timer Task is done.\n"));
return done_;
}
void ACE_ES_Reactor_Task::threads_closed()
{
delete this;
}
void ACE_ES_Reactor_Task::shutdown_task()
{
done_ = 1;
reactor_.notify();
}
ACE_ES_Reactor_Task::Reactor&
ACE_ES_Reactor_Task::get_reactor()
{
return reactor_;
}
|