diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-09-03 20:38:55 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-09-03 20:38:55 +0000 |
commit | ae8ed092cd73954b32ac325d0f164b6e3b5f860c (patch) | |
tree | eb84956a19b2e4eecad36662657f7a1190cfdd3a | |
parent | bc6bba88188f261b8af13e8dac6219cfd7d52fe6 (diff) | |
download | ATCD-ae8ed092cd73954b32ac325d0f164b6e3b5f860c.tar.gz |
*** empty log message ***
-rw-r--r-- | tests/Makefile | 1 | ||||
-rw-r--r-- | tests/Upgradable_RW_Test.cpp | 166 | ||||
-rw-r--r-- | tests/Upgradable_RW_Test.h | 34 | ||||
-rw-r--r-- | tests/run_tests.bat | 1 | ||||
-rwxr-xr-x | tests/run_tests.sh | 1 |
5 files changed, 100 insertions, 103 deletions
diff --git a/tests/Makefile b/tests/Makefile index fa76a37965f..303d7ecd88d 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -66,6 +66,7 @@ BIN = Aio_Platform_Test \ Tokens_Test \ TSS_Test \ UPIPE_SAP_Test \ + Upgradable_RW_Test \ XtReactor_Test LSRC = $(addsuffix .cpp,$(BIN)) diff --git a/tests/Upgradable_RW_Test.cpp b/tests/Upgradable_RW_Test.cpp index 8367521ef34..aaa0d870e3c 100644 --- a/tests/Upgradable_RW_Test.cpp +++ b/tests/Upgradable_RW_Test.cpp @@ -25,7 +25,7 @@ ACE_RCSID(tests, Upgradable_RW_Test, "$Id$") #if defined (__BORLANDC__) && __BORLANDC__ >= 0x0530 -USELIB ("..\ace\aced.lib"); + USELIB ("..\ace\aced.lib"); //--------------------------------------------------------------------------- #endif /* defined (__BORLANDC__) && __BORLANDC__ >= 0x0530 */ @@ -66,9 +66,9 @@ static u_int not_upgraded = 0; // Lock for shared_data (upgraded, not_upgraded, hash_Map) #if defined RW_MUTEX - static ACE_RW_Thread_Mutex rw_mutex; +static ACE_RW_Thread_Mutex rw_mutex; #else - static ACE_Thread_Mutex mutex; +static ACE_Thread_Mutex mutex; #endif // Count of the number of readers and writers. @@ -97,11 +97,11 @@ find_last () for (ACE_Double_Linked_List_Iterator<Element> iterator(*linked_List_ptr); !iterator.done(); iterator.advance()) - { - if (element_ptr = iterator.next()) - if (*element_ptr->value() == cString) - return 1; - } + { + if ((element_ptr = iterator.next())) + if (*element_ptr->value() == cString) + return 1; + } return 0; @@ -126,26 +126,26 @@ parse_args (int argc, ASYS_TCHAR *argv[]) while ((c = get_opt ()) != -1) switch (c) - { - case 'e': - n_entries = ACE_OS::atoi (get_opt.optarg); - break; - case 'r': - n_readers = ACE_OS::atoi (get_opt.optarg); - break; - case 'w': - n_writers = ACE_OS::atoi (get_opt.optarg); - break; - case 'n': - n_iterations = ACE_OS::atoi (get_opt.optarg); - break; - case 'u': - use_try_upgrade = 1; - break; - default: - print_usage_and_die (); - break; - } + { + case 'e': + n_entries = ACE_OS::atoi (get_opt.optarg); + break; + case 'r': + n_readers = ACE_OS::atoi (get_opt.optarg); + break; + case 'w': + n_writers = ACE_OS::atoi (get_opt.optarg); + break; + case 'n': + n_iterations = ACE_OS::atoi (get_opt.optarg); + break; + case 'u': + use_try_upgrade = 1; + break; + default: + print_usage_and_die (); + break; + } } // Iterate <n_iterations> each time checking that nobody modifies the data @@ -175,9 +175,9 @@ Reader_Task::svc () { #if defined RW_MUTEX - ACE_Read_Guard<ACE_RW_Thread_Mutex> g (rw_mutex); + ACE_Read_Guard<ACE_RW_Thread_Mutex> g (rw_mutex); #else - ACE_Guard<ACE_Thread_Mutex> g (mutex); + ACE_Guard<ACE_Thread_Mutex> g (mutex); #endif find_last (); @@ -203,9 +203,9 @@ Reader_Task::svc () || !use_try_upgrade) // we did not try at all { #if defined RW_MUTEX - ACE_Write_Guard<ACE_RW_Thread_Mutex> g (rw_mutex); + ACE_Write_Guard<ACE_RW_Thread_Mutex> g (rw_mutex); #else - ACE_Guard<ACE_Thread_Mutex> g (mutex); + ACE_Guard<ACE_Thread_Mutex> g (mutex); #endif not_upgraded++; @@ -303,20 +303,20 @@ Time_Calculation ::print_stats () double tmp = 1000 / elapsed_time.real_time; ACE_DEBUG ((LM_DEBUG,ASYS_TEXT ("\n" - "\treal_time\t = %0.06f ms, \n" - "\tuser_time\t = %0.06f ms, \n" - "\tsystem_time\t = %0.06f ms, \n" - "\t%0.00f calls/second\n"), + "\treal_time\t = %0.06f ms, \n" + "\tuser_time\t = %0.06f ms, \n" + "\tsystem_time\t = %0.06f ms, \n" + "\t%0.00f calls/second\n"), elapsed_time.real_time < 0.0 ? 0.0 : elapsed_time.real_time, elapsed_time.user_time < 0.0 ? 0.0 : elapsed_time.user_time, elapsed_time.system_time < 0.0 ? 0.0 : elapsed_time.system_time, tmp < 0.0 ? 0.0 : tmp)); ACE_DEBUG ((LM_DEBUG, - ASYS_TEXT ("Number of reported times: %d\n"), - this->reported_times_)); + ASYS_TEXT ("Number of reported times: %d\n"), + this->reported_times_)); - } + } else ACE_ERROR ((LM_ERROR, "\tNo time stats printed. Zero iterations or error ocurred.\n")); @@ -335,13 +335,13 @@ init () -1); for (unsigned long i = 0; i < n_entries; i++) - { - ACE_OS::sprintf(entry,"%d",i); - ACE_NEW_RETURN (cString_ptr, ACE_CString(entry), -1); - ACE_NEW_RETURN (element_ptr, Element(cString_ptr), -1); + { + ACE_OS::sprintf(entry,"%d",i); + ACE_NEW_RETURN (cString_ptr, ACE_CString(entry), -1); + ACE_NEW_RETURN (element_ptr, Element(cString_ptr), -1); - linked_List_ptr->insert_tail(element_ptr); - } + linked_List_ptr->insert_tail(element_ptr); + } return 0; } @@ -374,8 +374,8 @@ int main (int argc, ASYS_TCHAR *argv[]) parse_args (argc, argv); #if !defined RW_MUTEX - use_try_upgrade = 0; - // make sure that we have to acquire the write lock + use_try_upgrade = 0; + // make sure that we have to acquire the write lock #endif @@ -405,16 +405,16 @@ int main (int argc, ASYS_TCHAR *argv[]) for (i = 0; i < n_readers; i++) - { - ACE_NEW_RETURN (reader_tasks[i], - Reader_Task(time_Calculation, - barrier), - -1); - reader_tasks[i]->activate (THR_BOUND | ACE_SCHED_FIFO, - 1, - 0, - ACE_DEFAULT_THREAD_PRIORITY); - } + { + ACE_NEW_RETURN (reader_tasks[i], + Reader_Task(time_Calculation, + barrier), + -1); + reader_tasks[i]->activate (THR_BOUND | ACE_SCHED_FIFO, + 1, + 0, + ACE_DEFAULT_THREAD_PRIORITY); + } // Create all the writers @@ -428,20 +428,18 @@ int main (int argc, ASYS_TCHAR *argv[]) for (i = 0; i < n_writers; i++) - { - ACE_NEW_RETURN (writer_tasks[i], - Writer_Task(time_Calculation, - barrier), - -1); - writer_tasks[i]->activate (THR_BOUND | ACE_SCHED_FIFO, - 1, - 0, - ACE_DEFAULT_THREAD_PRIORITY); - } - - + { + ACE_NEW_RETURN (writer_tasks[i], + Writer_Task(time_Calculation, + barrier), + -1); + writer_tasks[i]->activate (THR_BOUND | ACE_SCHED_FIFO, + 1, + 0, + ACE_DEFAULT_THREAD_PRIORITY); + } - int result = ACE_Thread_Manager::instance ()->wait (); + ACE_Thread_Manager::instance ()->wait (); // compute average time. time_Calculation.print_stats (); @@ -465,14 +463,14 @@ int main (int argc, ASYS_TCHAR *argv[]) for (i = 0; i < n_entries; i++) - { - if (element_ptr = linked_List_ptr->delete_head()) - { - cString_ptr = element_ptr->value(); - delete cString_ptr; - delete element_ptr; - } - } + { + if ((element_ptr = linked_List_ptr->delete_head())) + { + cString_ptr = element_ptr->value(); + delete cString_ptr; + delete element_ptr; + } + } delete linked_List_ptr; #else @@ -486,13 +484,9 @@ int main (int argc, ASYS_TCHAR *argv[]) } #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) -template class ACE_Hash_Map_Entry<MAP_STRING, MAP_STRING>; -template class ACE_Hash_Map_Manager<MAP_STRING, MAP_STRING, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator<MAP_STRING, MAP_STRING, ACE_Null_Mutex>; -template class ACE_Hash_Map_Iterator_Base<MAP_STRING, MAP_STRING, ACE_Null_Mutex>; +template class ACE_Double_Linked_List<Element>; +template class ACE_Double_Linked_List_Iterator<Element>; #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA) -#pragma instantiate ACE_Hash_Map_Entry<MAP_STRING, MAP_STRING> -#pragma instantiate ACE_Hash_Map_Manager<MAP_STRING, MAP_STRING, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator<MAP_STRING, MAP_STRING, ACE_Null_Mutex> -#pragma instantiate ACE_Hash_Map_Iterator_Base<MAP_STRING, MAP_STRING, ACE_Null_Mutex> +#pragma instantiate ACE_Double_Linked_List<Element> +#pragma instantiate ACE_Double_Linked_List_Iterator<Element> #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */ diff --git a/tests/Upgradable_RW_Test.h b/tests/Upgradable_RW_Test.h index 687c4e4c0fe..4fd6a25a5b9 100644 --- a/tests/Upgradable_RW_Test.h +++ b/tests/Upgradable_RW_Test.h @@ -38,14 +38,14 @@ class Element public: Element (ACE_CString* item = 0, Element* p = 0, Element* n = 0) - : item_(item), prev_(p), next_(n) - { - } + : prev_ (p), next_(n), item_(item) + { + } ACE_CString* value (void) - { - return this->item_; - } + { + return this->item_; + } private: Element* next_; @@ -64,11 +64,11 @@ class Time_Calculation public: Time_Calculation () : reported_times_ (0) - { - times_.real_time = 0; - times_.user_time = 0; - times_.system_time = 0; - } + { + times_.real_time = 0; + times_.user_time = 0; + times_.system_time = 0; + } void report_time (ACE_Profile_Timer::ACE_Elapsed_Time &elapsed_time); // take the time of the thread and add it to @@ -95,9 +95,9 @@ public: Reader_Task (Time_Calculation &time_Calculation, ACE_Barrier &barrier) : time_Calculation_ (time_Calculation), - barrier_(barrier) - { - }; + barrier_(barrier) + { + }; virtual int svc (void); @@ -119,9 +119,9 @@ public: Writer_Task (Time_Calculation &time_Calculation, ACE_Barrier &barrier) : time_Calculation_ (time_Calculation), - barrier_(barrier) - { - }; + barrier_(barrier) + { + }; virtual int svc (void); diff --git a/tests/run_tests.bat b/tests/run_tests.bat index 9c02f1d16f9..26df5be67d6 100644 --- a/tests/run_tests.bat +++ b/tests/run_tests.bat @@ -75,6 +75,7 @@ call %0 %dopure% Time_Value_Test call %0 %dopure% Tokens_Test call %0 %dopure% TSS_Test call %0 %dopure% UPIPE_SAP_Test +call %0 %dopure% Upgradable_RW_Test goto done diff --git a/tests/run_tests.sh b/tests/run_tests.sh index a35e65cc66b..dd96ac98f16 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -135,6 +135,7 @@ run Service_Config_Test # uses Service_Config run Priority_Task_Test # uses Task with priorities run IOStream_Test # uses ACE_IOStream and ACE_SOCK_Stream run Enum_Interfaces_Test # uses ACE::get_ip_interfaces() +run Upgradable_RW_Test # uses RW locks test $chorus || run Conn_Test # uses Thread_Manager, Acceptor/Connector, SOCK_SAP echo "Tests complete..." |