Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / ACE / apps / JAWS2 / JAWS / Waiter.cpp
blobb35e560b05bad03322a1551cf8e3a034a1d2ddac
1 #include "ace/Proactor.h"
3 #include "JAWS/Waiter.h"
4 #include "JAWS/IO_Handler.h"
8 JAWS_Waiter::JAWS_Waiter (void)
9 : iter_ (*this)
13 JAWS_Waiter::~JAWS_Waiter (void)
17 JAWS_Waiter_Base_Iterator &
18 JAWS_Waiter::iter (void)
20 return this->iter_;
23 int
24 JAWS_Waiter::index (void)
26 #if 0
27 // A future version of ACE will support this.
28 ACE_Thread_ID tid = ACE_OS::thr_self ();
29 #else
30 // Do it this way for now
31 ACE_thread_t thr_name;
32 thr_name = ACE_OS::thr_self ();
34 JAWS_Thread_ID tid (thr_name);
35 #endif /* 0 */
37 return JAWS_Waiter_Base::index (tid);
40 JAWS_IO_Handler *
41 JAWS_Waiter::wait_for_completion (int i)
43 JAWS_IO_Handler *ioh;
44 JAWS_IO_Handler **iohptr;
46 iohptr = (i >= 0) ? this->find_by_index (i) : this->find_by_index (this->index ());
48 while (*iohptr == 0)
49 if (ACE_Proactor::instance ()->handle_events () == -1)
51 ACE_ERROR ((LM_ERROR, "%p\n", "JAWS_Waiter::wait_for_completion"));
52 return 0;
55 ioh = *iohptr;
56 *iohptr = 0;
58 ioh->lock ();
59 ioh->release ();
60 return ioh;