Merge branch 'master' into jwi-bcc64xsingletonwarning
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / Waiter.cpp
blobaaa1f691d775af54a99ca52b6687b6c7f823838d
1 #include "ace/Proactor.h"
3 #include "JAWS/Waiter.h"
4 #include "JAWS/IO_Handler.h"
7 JAWS_Waiter::JAWS_Waiter ()
8 : iter_ (*this)
12 JAWS_Waiter::~JAWS_Waiter ()
16 JAWS_Waiter_Base_Iterator &
17 JAWS_Waiter::iter ()
19 return this->iter_;
22 int
23 JAWS_Waiter::index ()
25 #if 0
26 // A future version of ACE will support this.
27 ACE_Thread_ID tid = ACE_OS::thr_self ();
28 #else
29 // Do it this way for now
30 ACE_thread_t thr_name;
31 thr_name = ACE_OS::thr_self ();
33 JAWS_Thread_ID tid (thr_name);
34 #endif /* 0 */
36 return JAWS_Waiter_Base::index (tid);
39 JAWS_IO_Handler *
40 JAWS_Waiter::wait_for_completion (int i)
42 JAWS_IO_Handler *ioh;
43 JAWS_IO_Handler **iohptr;
45 iohptr = (i >= 0) ? this->find_by_index (i) : this->find_by_index (this->index ());
47 while (*iohptr == 0)
48 if (ACE_Proactor::instance ()->handle_events () == -1)
50 ACE_ERROR ((LM_ERROR, "%p\n", "JAWS_Waiter::wait_for_completion"));
51 return 0;
54 ioh = *iohptr;
55 *iohptr = 0;
57 ioh->lock ();
58 ioh->release ();
59 return ioh;