diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-07-27 20:14:18 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-07-27 20:14:18 +0000 |
commit | a32709127ed8f73d6b3b935414f676817b414b80 (patch) | |
tree | ea50db4f172833b1cd258ceefd2a688baa709d53 | |
parent | 37f426c784885e2e5c04996a8672838986727961 (diff) | |
download | ATCD-a32709127ed8f73d6b3b935414f676817b414b80.tar.gz |
*** empty log message ***
-rw-r--r-- | ace/Handle_Set.i | 25 | ||||
-rw-r--r-- | tests/Handle_Set_Test.cpp | 55 | ||||
-rw-r--r-- | tests/Reactor_Timer_Test.cpp | 2 |
3 files changed, 57 insertions, 25 deletions
diff --git a/ace/Handle_Set.i b/ace/Handle_Set.i index e6d9265076d..b52566b3df1 100644 --- a/ace/Handle_Set.i +++ b/ace/Handle_Set.i @@ -116,21 +116,30 @@ ACE_Handle_Set_Iterator::operator () (void) { ACE_HANDLE result = this->handle_index_; - // Increment the iterator. + // Increment the iterator and advance to the next bit in this + // word. this->handle_index_++; this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK; - // If've examined all the bits in this word, we'll go onto the - // next word. + // If we've examined all the bits in this word, we'll go onto + // the next word. if (this->word_val_ == 0) { - // Loop until we've found the first non-zero bit or we run - // past the <maxhandlep1> of the bitset. - while (this->handle_index_ < maxhandlep1 - && this->handles_.mask_.fds_bits[++this->word_num_] == 0) + // Start the handle_index_ at the beginning of the next word + // and then loop until we've found the first non-zero bit or + // we run past the <maxhandlep1> of the bitset. + + for (this->handle_index_ = ++this->word_num_ * ACE_Handle_Set::WORDSIZE; + this->handle_index_ < maxhandlep1 + && this->handles_.mask_.fds_bits[this->word_num_] == 0; + this->word_num_++) this->handle_index_ += ACE_Handle_Set::WORDSIZE; + ACE_DEBUG ((LM_DEBUG, + "handle_index_: %d, maxhandlep1: %d, word_num_: %d\n", + handle_index_, maxhandlep1, word_num_)); + // If the bit index becomes >= the maxhandlep1 that means // there weren't any more bits set that we want to consider. // Therefore, we'll just store the maxhandlep1, which will @@ -151,7 +160,7 @@ ACE_Handle_Set_Iterator::operator () (void) // represents (this information is used by subsequent calls to // <operator()>). - for (; + for (; ACE_BIT_DISABLED (this->word_val_, 1); this->handle_index_++) this->word_val_ = (this->word_val_ >> 1) & ACE_MSB_MASK; diff --git a/tests/Handle_Set_Test.cpp b/tests/Handle_Set_Test.cpp index 5b72b75f4f4..adc0c53ad4b 100644 --- a/tests/Handle_Set_Test.cpp +++ b/tests/Handle_Set_Test.cpp @@ -20,6 +20,7 @@ #include "ace/Profile_Timer.h" #include "ace/Handle_Set.h" +#include "ace/Containers.h" #include "test_config.h" static void @@ -59,11 +60,28 @@ test_duplicates (size_t count) ACE_ASSERT (handle_set.num_set () + duplicates == sets); } +// This is the vector of handles to test. These numbers are chosen to +// test for boundaries conditions. +static ACE_HANDLE handle_vector[] = +{ + (ACE_HANDLE) 0, + (ACE_HANDLE) 1, + (ACE_HANDLE) 32, + (ACE_HANDLE) 63, + (ACE_HANDLE) 64, + (ACE_HANDLE) 65, + (ACE_HANDLE) 127, + (ACE_HANDLE) 128, + (ACE_HANDLE) 129, + (ACE_HANDLE) 255, + ACE_INVALID_HANDLE +}; + static void test_boundaries (void) { ACE_Handle_Set handle_set; - + ACE_Unbounded_Queue<int> queue; ACE_HANDLE handle; // First test an empty set. @@ -73,26 +91,27 @@ test_boundaries (void) while ((handle = i1 ()) != ACE_INVALID_HANDLE) ACE_ASSERT (!"this shouldn't get called since the set is empty!\n"); - // Insert a bunch of HANDLEs into the set, testing for boundary - // conditions. + // Insert the vector of HANDLEs into the set. - handle_set.set_bit ((ACE_HANDLE) 0); - handle_set.set_bit ((ACE_HANDLE) 1); - handle_set.set_bit ((ACE_HANDLE) 32); - handle_set.set_bit ((ACE_HANDLE) 63); - handle_set.set_bit ((ACE_HANDLE) 64); - handle_set.set_bit ((ACE_HANDLE) 65); - handle_set.set_bit ((ACE_HANDLE) 127); - handle_set.set_bit ((ACE_HANDLE) 128); - handle_set.set_bit ((ACE_HANDLE) 129); - handle_set.set_bit ((ACE_HANDLE) 255); + for (int i = 0; + handle_vector[i] != ACE_INVALID_HANDLE; + i++) + { + handle_set.set_bit (handle_vector[i]); + queue.enqueue_tail (handle_vector[i]); + } int count = 0; ACE_Handle_Set_Iterator i2 (handle_set); while ((handle = i2 ()) != ACE_INVALID_HANDLE) - count++; + { + ACE_HANDLE temp; + queue.dequeue_head (temp); + ACE_ASSERT (handle == temp); + count++; + } ACE_ASSERT (count == handle_set.num_set ()); } @@ -151,11 +170,15 @@ main (int argc, char *argv[]) size_t max_handles = argc > 2 ? ACE_OS::atoi (argv[2]) : ACE_Handle_Set::MAXSIZE; size_t max_iterations = argc > 3 ? ACE_OS::atoi (argv[3]) : ACE_MAX_ITERATIONS; - test_duplicates (count); + // test_duplicates (count); test_boundaries (); - test_performance (max_handles, max_iterations); + // test_performance (max_handles, max_iterations); ACE_END_TEST; return 0; } +#if defined (ACE_TEMPLATES_REQUIRE_SPECIALIZATION) +template class ACE_Unbounded_Queue<int>; +template class ACE_Node<int>; +#endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ diff --git a/tests/Reactor_Timer_Test.cpp b/tests/Reactor_Timer_Test.cpp index 48d688e1cbc..1270a5b75ea 100644 --- a/tests/Reactor_Timer_Test.cpp +++ b/tests/Reactor_Timer_Test.cpp @@ -15,7 +15,7 @@ // command line arguments are needed to run the test. // // = AUTHOR -// Prashant Jain and Doug C. Schmidt +// Prashant Jain and Douglas C. Schmidt // // ============================================================================ |