blob: 219503a22d77d08f089ceb8527b4ba3af1f06941 (
plain)
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
|
// $Id$
#include "tpool.h"
Thread_Pool::Thread_Pool (int n_threads)
: ACE_Task<ACE_MT_SYNCH> (ACE_Thread_Manager::instance ())
{
if (this->activate (THR_DETACHED | THR_NEW_LWP, n_threads) == -1)
ACE_ERROR ((LM_ERROR, "%p\n", "activate failed"));
}
int
Thread_Pool::svc (void)
{
cout << "Pool thread activated" << endl;
while (1)
{
// Dequeue message
ACE_Message_Block *mb;
this->msg_queue ()->dequeue_head (mb);
CORBA::Request *vp = (CORBA::Request *) mb->base ();
mb->release ();
// Hand it off to Orbix
CORBA::Orbix.continueThreadDispatch (*vp);
}
return -1;
}
int
Thread_Pool::inRequestPreMarshal(CORBA::Request &r, CORBA::Environment&)
{
// thread_t tid;
// thr_create(NULL, 0, worker, (void *)&r, THR_DETACHED, &tid);
// Enqueue the request
ACE_Message_Block *mb = new ACE_Message_Block ( (char *) (&r));
this->msg_queue ()->enqueue (mb);
// Done
return -1;
}
|