diff options
author | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-12-03 15:20:36 +0000 |
---|---|---|
committer | levine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-12-03 15:20:36 +0000 |
commit | 2d2e715e9b4d48ad8bb6593223feb8f536c263a5 (patch) | |
tree | ae4b6e80056fe019c2f10b579cd935cdaaf1c7c4 | |
parent | 3338bb2053813dd4a32801ae57c8bb03574d4b0c (diff) | |
download | ATCD-2d2e715e9b4d48ad8bb6593223feb8f536c263a5.tar.gz |
moved ACE_Atomic_Op<ACE_Thread_Mutex, int> instantiation from ace/Future.cpp to where it is used
-rw-r--r-- | ace/Future.cpp | 13 | ||||
-rw-r--r-- | examples/Threads/manual_event.cpp | 37 | ||||
-rw-r--r-- | tests/Future_Test.cpp | 163 | ||||
-rw-r--r-- | tests/Reactors_Test.cpp | 87 | ||||
-rw-r--r-- | tests/Reader_Writer_Test.cpp | 54 |
5 files changed, 180 insertions, 174 deletions
diff --git a/ace/Future.cpp b/ace/Future.cpp index 75eee48a85f..0b269abd850 100644 --- a/ace/Future.cpp +++ b/ace/Future.cpp @@ -282,7 +282,7 @@ ACE_Future<T>::operator = (const ACE_Future<T> &rhs) // This will work if &r == this, by first increasing the ref count ACE_Future<T> &r = ( ACE_Future<T> &) rhs; FUTURE_REP::assign (this->future_rep_, - FUTURE_REP::attach (r.future_rep_)); + FUTURE_REP::attach (r.future_rep_)); } template <class T> void @@ -311,16 +311,5 @@ ACE_Future<T>::operator &() { } -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -// This should probably be moved elsewhere now that ACE_Atomic_Op<> -// isn't used. -template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -// This should probably be moved elsewhere now that ACE_Atomic_Op<> -// isn't used. -#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - - #endif /* ACE_HAS_THREADS */ #endif /* ACE_FUTURE_CPP */ diff --git a/examples/Threads/manual_event.cpp b/examples/Threads/manual_event.cpp index e59ae62e7e1..0ccf520b54b 100644 --- a/examples/Threads/manual_event.cpp +++ b/examples/Threads/manual_event.cpp @@ -4,10 +4,10 @@ // Pseudo_Barrier. Multiple threads are created which do the // following: // -// 1. work -// 2. synch with other threads -// 3. more work -// +// 1. work +// 2. synch with other threads +// 3. more work +// // ACE_Manual_Event is use to synch with other // threads. ACE_Manual_Event::signal() is used for broadcasting. @@ -23,9 +23,9 @@ class Pseudo_Barrier // A barrier class using ACE manual-reset events. // // = DESCRIPTION - // This is *not* a real barrier. + // This is *not* a real barrier. // Pseudo_Barrier is more like a ``one shot'' barrier. - // All waiters after the Nth waiter are allowed to go. + // All waiters after the Nth waiter are allowed to go. // The barrier does not reset after the Nth waiter. // For an example of a real barrier, please see class ACE_Barrier. { @@ -34,8 +34,8 @@ public: int wait (void); -private: - ACE_Atomic_Op <ACE_Thread_Mutex, int> counter_; +private: + ACE_Atomic_Op <ACE_Thread_Mutex, int> counter_; ACE_Manual_Event event_; }; @@ -44,12 +44,12 @@ Pseudo_Barrier::Pseudo_Barrier (u_long count) { } -int +int Pseudo_Barrier::wait (void) { if (--this->counter_ == 0) return this->event_.signal (); - else + else return this->event_.wait (); } @@ -57,7 +57,7 @@ static void * worker (void *arg) { Pseudo_Barrier &barrier = *(Pseudo_Barrier *) arg; - + // work ACE_DEBUG ((LM_DEBUG, "(%t) working (%d secs)\n", ++::amount_of_work)); ACE_OS::sleep (::amount_of_work.value ()); @@ -75,13 +75,13 @@ worker (void *arg) return 0; } -int +int main (int argc, char **argv) { int n_threads = argc == 2 ? atoi (argv[1]) : 5; ACE_Thread_Manager &tm = *ACE_Thread_Manager::instance (); - + // synch object shared by all threads Pseudo_Barrier barrier (n_threads); @@ -92,13 +92,20 @@ main (int argc, char **argv) // wait for all workers to exit if (tm.wait () == -1) ACE_ERROR_RETURN ((LM_ERROR, "thread wait failed"), -1); - else + else ACE_DEBUG ((LM_ERROR, "graceful exit\n")); return 0; } + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #else -int +int main (int, char *[]) { ACE_ERROR ((LM_ERROR, "threads not supported on this platform\n")); diff --git a/tests/Future_Test.cpp b/tests/Future_Test.cpp index e6f6716009f..945daaf4ca4 100644 --- a/tests/Future_Test.cpp +++ b/tests/Future_Test.cpp @@ -85,22 +85,22 @@ private: }; Method_Object_work::Method_Object_work (Scheduler* new_Scheduler, - u_long new_param, - int new_count, - ACE_Future<u_long> &new_result) + u_long new_param, + int new_count, + ACE_Future<u_long> &new_result) : scheduler_ (new_Scheduler), param_ (new_param), count_ (new_count), future_result_ (new_result) { ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_work created\n")); + "(%t) Method_Object_work created\n")); } Method_Object_work::~Method_Object_work (void) { ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_work will be deleted.\n")); + "(%t) Method_Object_work will be deleted.\n")); } @@ -109,7 +109,7 @@ Method_Object_work::call (void) { return this->future_result_.set (this->scheduler_->work_i (this->param_, - this->count_)); + this->count_)); } class Method_Object_name : public ACE_Method_Object @@ -118,7 +118,7 @@ class Method_Object_name : public ACE_Method_Object { public: Method_Object_name (Scheduler *, - ACE_Future<const char*> &); + ACE_Future<const char*> &); virtual ~Method_Object_name (void); virtual int call (void); @@ -128,18 +128,18 @@ private: }; Method_Object_name::Method_Object_name (Scheduler *new_scheduler, - ACE_Future<const char*> &new_result) + ACE_Future<const char*> &new_result) : scheduler_ (new_scheduler), future_result_ (new_result) { ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_name created\n")); + "(%t) Method_Object_name created\n")); } Method_Object_name::~Method_Object_name (void) { ACE_DEBUG ((LM_DEBUG, - "(%t) Method_Object_name will be deleted.\n")); + "(%t) Method_Object_name will be deleted.\n")); } int @@ -167,22 +167,22 @@ private: // constructor Scheduler::Scheduler (const char *newname, - Scheduler *new_Scheduler) + Scheduler *new_Scheduler) { ACE_NEW (this->name_, char[ACE_OS::strlen (newname) + 1]); ACE_OS::strcpy ((char *) this->name_, newname); this->scheduler_ = new_Scheduler; ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s created\n", - this->name_)); + "(%t) Scheduler %s created\n", + this->name_)); } // Destructor Scheduler::~Scheduler (void) { ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s will be destroyed\n", - this->name_)); + "(%t) Scheduler %s will be destroyed\n", + this->name_)); delete[] this->name_; } @@ -192,8 +192,8 @@ Scheduler::open (void *) { task_count++; ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s open\n", - this->name_)); + "(%t) Scheduler %s open\n", + this->name_)); // Become an Active Object. return this->activate (THR_BOUND | THR_DETACHED); } @@ -203,8 +203,8 @@ int Scheduler::close (u_long) { ACE_DEBUG ((LM_DEBUG, - "(%t) Scheduler %s close\n", - this->name_)); + "(%t) Scheduler %s close\n", + this->name_)); task_count--; return 0; } @@ -222,7 +222,7 @@ Scheduler::svc (void) ACE_DEBUG ((LM_DEBUG, "(%t) calling method object\n")); // Call it. if (mo->call () == -1) - break; + break; // Destructor automatically deletes it. } @@ -240,7 +240,7 @@ Scheduler::end (void) // Here's where the Work takes place. u_long Scheduler::work_i (u_long param, - int count) + int count) { ACE_UNUSED_ARG (count); @@ -265,7 +265,7 @@ Scheduler::name (void) // @@ What happens if new fails here? this->activation_queue_.enqueue - (new Method_Object_name (this, new_future)); + (new Method_Object_name (this, new_future)); return new_future; } @@ -282,7 +282,7 @@ Scheduler::work (u_long newparam, int newcount) this->activation_queue_.enqueue (new Method_Object_work (this, newparam, - newcount, new_future)); + newcount, new_future)); return new_future; } } @@ -293,6 +293,7 @@ Scheduler::work (u_long newparam, int newcount) static int n_loops = 100; #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; template class ACE_Future<const char *>; template class ACE_Future<int>; template class ACE_Future<u_long>; @@ -302,6 +303,7 @@ template class ACE_Future_Rep<u_long>; template class auto_ptr<ACE_Method_Object>; template class ACE_Auto_Basic_Ptr<ACE_Method_Object>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> #pragma instantiate ACE_Future<const char *> #pragma instantiate ACE_Future<int> #pragma instantiate ACE_Future<u_long> @@ -312,7 +314,6 @@ template class ACE_Auto_Basic_Ptr<ACE_Method_Object>; #pragma instantiate ACE_Auto_Basic_Ptr<ACE_Method_Object> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - #endif /* ACE_HAS_THREADS */ int @@ -340,68 +341,68 @@ main (int, char *[]) for (int i = 0; i < n_loops; i++) { { - ACE_Future<u_long> fresulta, fresultb, fresultc, fresultd, fresulte; - ACE_Future<const char*> fname; + ACE_Future<u_long> fresulta, fresultb, fresultc, fresultd, fresulte; + ACE_Future<const char*> fname; - ACE_DEBUG ((LM_DEBUG, - "(%t) going to do a non-blocking call\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) going to do a non-blocking call\n")); - fresulta = andres->work (9013); - fresultb = peter->work (9013); - fresultc = helmut->work (9013); - fresultd = matias->work (9013); - fname = andres->name (); + fresulta = andres->work (9013); + fresultb = peter->work (9013); + fresultc = helmut->work (9013); + fresultd = matias->work (9013); + fname = andres->name (); - // see if the result is available... - if (fresulta.ready ()) - ACE_DEBUG ((LM_DEBUG, - "(%t) wow.. work is ready.....\n")); + // see if the result is available... + if (fresulta.ready ()) + ACE_DEBUG ((LM_DEBUG, + "(%t) wow.. work is ready.....\n")); - ACE_DEBUG ((LM_DEBUG, - "(%t) non-blocking call done... now blocking...\n")); + ACE_DEBUG ((LM_DEBUG, + "(%t) non-blocking call done... now blocking...\n")); - // Save the result of fresulta. + // Save the result of fresulta. - fresulte = fresulta; + fresulte = fresulta; - if (i % 3 == 0) - { - // Every 3rd time... disconnect the futures... - // but "fresulte" should still contain the result... - fresulta.cancel (10ul); - fresultb.cancel (20ul); - fresultc.cancel (30ul); - fresultd.cancel (40ul); - } + if (i % 3 == 0) + { + // Every 3rd time... disconnect the futures... + // but "fresulte" should still contain the result... + fresulta.cancel (10ul); + fresultb.cancel (20ul); + fresultc.cancel (30ul); + fresultd.cancel (40ul); + } - u_long resulta = 0, resultb = 0, resultc = 0, resultd = 0, resulte = 0; + u_long resulta = 0, resultb = 0, resultc = 0, resultd = 0, resulte = 0; - fresulta.get (resulta); - fresultb.get (resultb); - fresultc.get (resultc); - fresultd.get (resultd); - fresulte.get (resulte); + fresulta.get (resulta); + fresultb.get (resultb); + fresultc.get (resultc); + fresultd.get (resultd); + fresulte.get (resulte); - ACE_DEBUG ((LM_DEBUG, "(%t) result a %u\n", (u_int) resulte)); - ACE_DEBUG ((LM_DEBUG, "(%t) result b %u\n", (u_int) resulta)); - ACE_DEBUG ((LM_DEBUG, "(%t) result c %u\n", (u_int) resultb)); - ACE_DEBUG ((LM_DEBUG, "(%t) result d %u\n", (u_int) resultc)); - ACE_DEBUG ((LM_DEBUG, "(%t) result e %u\n", (u_int) resultd)); + ACE_DEBUG ((LM_DEBUG, "(%t) result a %u\n", (u_int) resulte)); + ACE_DEBUG ((LM_DEBUG, "(%t) result b %u\n", (u_int) resulta)); + ACE_DEBUG ((LM_DEBUG, "(%t) result c %u\n", (u_int) resultb)); + ACE_DEBUG ((LM_DEBUG, "(%t) result d %u\n", (u_int) resultc)); + ACE_DEBUG ((LM_DEBUG, "(%t) result e %u\n", (u_int) resultd)); - const char *name; + const char *name; - fname.get (name); + fname.get (name); - ACE_DEBUG ((LM_DEBUG, "(%t) name %s\n", name)); + ACE_DEBUG ((LM_DEBUG, "(%t) name %s\n", name)); } ACE_DEBUG ((LM_DEBUG, - "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", - task_count.value (), - future_count.value (), - capsule_count.value (), - methodobject_count.value ())); + "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", + task_count.value (), + future_count.value (), + capsule_count.value (), + methodobject_count.value ())); } // Close things down. @@ -413,12 +414,12 @@ main (int, char *[]) ACE_OS::sleep (2); ACE_DEBUG ((LM_DEBUG, - "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", - task_count.value (), - future_count.value (), - capsule_count.value (), - methodobject_count.value ())); - + "(%t) task_count %d future_count %d capsule_count %d methodobject_count %d\n", + task_count.value (), + future_count.value (), + capsule_count.value (), + methodobject_count.value ())); + { // Check if set then get works, older versions of ACE_Future // will lock forever (or until the timer expires), will use a small @@ -432,16 +433,16 @@ main (int, char *[]) if (f1.get (value, &timeout) == 0 && value == 100) ACE_DEBUG ((LM_DEBUG, - "Ace_Future<T>::Set followed by Ace_Future<T>::Get works.\n")); + "Ace_Future<T>::Set followed by Ace_Future<T>::Get works.\n")); else ACE_DEBUG ((LM_DEBUG, - "ACE_Future<T>::Set followed by Ace_Future<T>::Get does " - "not work, broken Ace_Future<> implementation.\n")); + "ACE_Future<T>::Set followed by Ace_Future<T>::Get does " + "not work, broken Ace_Future<> implementation.\n")); } { ACE_DEBUG ((LM_DEBUG, - "Checking if Ace_Future<T>::operator= is implemented " - "incorrectly this might crash the program.\n")); + "Checking if Ace_Future<T>::operator= is implemented " + "incorrectly this might crash the program.\n")); ACE_Future<int> f1; { @@ -498,7 +499,7 @@ main (int, char *[]) } } ACE_DEBUG ((LM_DEBUG, - "No it did not crash the program.\n")); + "No it did not crash the program.\n")); ACE_OS::sleep (5); diff --git a/tests/Reactors_Test.cpp b/tests/Reactors_Test.cpp index 2bbf2417357..2a9fccca07f 100644 --- a/tests/Reactors_Test.cpp +++ b/tests/Reactors_Test.cpp @@ -4,7 +4,7 @@ // // = LIBRARY // tests -// +// // = FILENAME // Reactors_Test.cpp // @@ -14,7 +14,7 @@ // // = AUTHOR // Prashant Jain, Detlef Becker, and Douglas C. Schmidt -// +// // ============================================================================ #include "test_config.h" @@ -43,8 +43,8 @@ public: // = Event Handler hooks. virtual int handle_input (ACE_HANDLE handle); - virtual int handle_close (ACE_HANDLE fd, - ACE_Reactor_Mask close_mask); + virtual int handle_close (ACE_HANDLE fd, + ACE_Reactor_Mask close_mask); private: int handled_; @@ -68,38 +68,38 @@ Test_Task::Test_Task (void) Test_Task::task_count_++; - ACE_DEBUG ((LM_DEBUG, - "(%t) TT+ Test_Task::task_count_ = %d\n", - Test_Task::task_count_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) TT+ Test_Task::task_count_ = %d\n", + Test_Task::task_count_)); } Test_Task::~Test_Task (void) { ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon, recursive_lock); - ACE_DEBUG ((LM_DEBUG, - "(%t) TT- Test_Task::task_count_ = %d\n", - Test_Task::task_count_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) TT- Test_Task::task_count_ = %d\n", + Test_Task::task_count_)); ACE_ASSERT (Test_Task::task_count_ == 0); } -int +int Test_Task::open (void *args) { this->reactor ((ACE_Reactor *) args); return this->activate (THR_NEW_LWP); } -int +int Test_Task::close (u_long) { ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, recursive_lock, -1); Test_Task::task_count_--; - ACE_DEBUG ((LM_DEBUG, - "(%t) close Test_Task::task_count_ = %d\n", - Test_Task::task_count_)); + ACE_DEBUG ((LM_DEBUG, + "(%t) close Test_Task::task_count_ = %d\n", + Test_Task::task_count_)); if (Test_Task::task_count_ < 0) abort (); @@ -107,7 +107,7 @@ Test_Task::close (u_long) return 0; } -int +int Test_Task::svc (void) { ACE_DEBUG ((LM_DEBUG, "(%t) svc\n")); @@ -120,26 +120,26 @@ Test_Task::svc (void) ACE_Time_Value timeout (0, 10 * 1000); if (this->reactor ()->notify (this, - ACE_Event_Handler::READ_MASK, - &timeout) == -1) - { - if (errno == ETIME) - ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "notify() timed out")); - else - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); - } + ACE_Event_Handler::READ_MASK, + &timeout) == -1) + { + if (errno == ETIME) + ACE_DEBUG ((LM_DEBUG, "(%t) %p\n", "notify() timed out")); + else + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "notify"), -1); + } } return 0; } -int +int Test_Task::handle_close (ACE_HANDLE, ACE_Reactor_Mask) { return 0; } -int +int Test_Task::handle_input (ACE_HANDLE) { this->handled_++; @@ -147,9 +147,9 @@ Test_Task::handle_input (ACE_HANDLE) if (this->handled_ == ACE_MAX_ITERATIONS) { done_count--; - ACE_DEBUG ((LM_DEBUG, - "(%t) handle_input, handled_ = %d, done_count = %d\n", - this->handled_, done_count.value ())); + ACE_DEBUG ((LM_DEBUG, + "(%t) handle_input, handled_ = %d, done_count = %d\n", + this->handled_, done_count.value ())); } ACE_OS::thr_yield (); @@ -170,22 +170,29 @@ worker (void *args) for (;;) { switch (reactor->handle_events (timeout)) - { - case -1: - ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "reactor"), 0); - /* NOTREACHED */ - case 0: - ACE_ERROR_RETURN ((LM_ERROR, "(%t) Reactor shutdown\n"), 0); - /* NOTREACHED */ - } + { + case -1: + ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "reactor"), 0); + /* NOTREACHED */ + case 0: + ACE_ERROR_RETURN ((LM_ERROR, "(%t) Reactor shutdown\n"), 0); + /* NOTREACHED */ + } } ACE_NOTREACHED (return 0); } + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ -int +int main (int, char *[]) { ACE_START_TEST ("Reactors_Test"); @@ -217,8 +224,8 @@ main (int, char *[]) THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); - else if (ACE_Thread_Manager::instance ()->spawn - (ACE_THR_FUNC (worker), (void *) &reactor, + else if (ACE_Thread_Manager::instance ()->spawn + (ACE_THR_FUNC (worker), (void *) &reactor, THR_BOUND | THR_DETACHED) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); diff --git a/tests/Reader_Writer_Test.cpp b/tests/Reader_Writer_Test.cpp index 1d72012cb44..b9e58cf8bfe 100644 --- a/tests/Reader_Writer_Test.cpp +++ b/tests/Reader_Writer_Test.cpp @@ -53,7 +53,7 @@ static void print_usage_and_die (void) { ACE_DEBUG ((LM_DEBUG, - "usage: %n [-r n_readers] [-w n_writers] [-n iteration_count]\n")); + "usage: %n [-r n_readers] [-w n_writers] [-n iteration_count]\n")); ACE_OS::exit (1); } @@ -108,12 +108,12 @@ reader (void *) for (size_t loop = 1; loop <= n_loops; loop++) { - ACE_Thread::yield (); + ACE_Thread::yield (); - if (!ACE_OS::thr_equal (shared_data, data)) + if (!ACE_OS::thr_equal (shared_data, data)) ACE_DEBUG ((LM_DEBUG, - " (%t) somebody changed %d to %d\n", - data, shared_data)); + " (%t) somebody changed %d to %d\n", + data, shared_data)); } --current_readers; @@ -158,12 +158,12 @@ writer (void *) for (size_t loop = 1; loop <= n_loops; loop++) { - ACE_Thread::yield (); + ACE_Thread::yield (); - if (!ACE_OS::thr_equal (shared_data, self)) + if (!ACE_OS::thr_equal (shared_data, self)) ACE_DEBUG ((LM_DEBUG, - " (%t) somebody wrote on my data %d\n", - shared_data)); + " (%t) somebody wrote on my data %d\n", + shared_data)); } --current_writers; @@ -176,6 +176,19 @@ writer (void *) return 0; } + +#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) +template class ACE_Atomic_Op<ACE_Thread_Mutex, int>; +template class ACE_Read_Guard<ACE_RW_Mutex>; +template class ACE_Write_Guard<ACE_RW_Mutex>; +template class ACE_Guard<ACE_RW_Mutex>; +#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) +#pragma instantiate ACE_Atomic_Op<ACE_Thread_Mutex, int> +#pragma instantiate ACE_Read_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Write_Guard<ACE_RW_Mutex> +#pragma instantiate ACE_Guard<ACE_RW_Mutex> +#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ + #endif /* ACE_HAS_THREADS */ // Spawn off threads. @@ -193,14 +206,14 @@ int main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, " (%t) main thread starting\n")); if (ACE_Thread_Manager::instance ()->spawn_n (n_readers, - ACE_THR_FUNC (reader), - 0, - THR_NEW_LWP) == -1) + ACE_THR_FUNC (reader), + 0, + THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); else if (ACE_Thread_Manager::instance ()->spawn_n (n_writers, - ACE_THR_FUNC (writer), - 0, - THR_NEW_LWP) == -1) + ACE_THR_FUNC (writer), + 0, + THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn_n"), 1); ACE_Thread_Manager::instance ()->wait (); @@ -214,14 +227,3 @@ int main (int argc, char *argv[]) ACE_END_TEST; return 0; } - -#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Read_Guard<ACE_RW_Mutex>; -template class ACE_Write_Guard<ACE_RW_Mutex>; -template class ACE_Guard<ACE_RW_Mutex>; -#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Read_Guard<ACE_RW_Mutex> -#pragma instantiate ACE_Write_Guard<ACE_RW_Mutex> -#pragma instantiate ACE_Guard<ACE_RW_Mutex> -#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ - |