From 8b4282ea05440501f99af7cf3929d650c95e5b87 Mon Sep 17 00:00:00 2001 From: schmidt Date: Tue, 22 Sep 1998 03:55:32 +0000 Subject: *** empty log message *** --- examples/Bounded_Packet_Relay/BPR_Drivers.cpp | 259 ++++++++++++++++++++- examples/Bounded_Packet_Relay/BPR_Drivers.h | 86 ++++++- examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp | 257 -------------------- examples/Bounded_Packet_Relay/BPR_Drivers_T.h | 91 +------- .../Thread_Bounded_Packet_Relay.cpp | 18 +- .../Thread_Bounded_Packet_Relay.h | 16 +- examples/Bounded_Packet_Relay/bpr_thread.cpp | 13 +- 7 files changed, 360 insertions(+), 380 deletions(-) (limited to 'examples') diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers.cpp b/examples/Bounded_Packet_Relay/BPR_Drivers.cpp index d576e6feb66..27f70fb4a33 100644 --- a/examples/Bounded_Packet_Relay/BPR_Drivers.cpp +++ b/examples/Bounded_Packet_Relay/BPR_Drivers.cpp @@ -23,9 +23,6 @@ // // ============================================================================ -#if !defined (_BPR_DRIVER_CPP_) -#define _BPR_DRIVER_CPP_ - #include "BPR_Drivers.h" ACE_RCSID(Bounded_Packet_Relay, BPR_Drivers, "$Id$") @@ -169,4 +166,258 @@ Input_Device_Wrapper_Base::send_input_message (ACE_Message_Block *amb) -1); } -#endif /* _BPR_DRIVER_CPP_ */ +// Constructor. + +Bounded_Packet_Relay::Bounded_Packet_Relay (ACE_Thread_Manager *input_task_mgr, + Input_Device_Wrapper_Base *input_wrapper, + Output_Device_Wrapper_Base *output_wrapper) + : input_task_mgr_ (input_task_mgr), + input_wrapper_ (input_wrapper), + output_wrapper_ (output_wrapper), + transmission_number_ (0), + packets_sent_ (0), + status_ (Bounded_Packet_Relay::UN_INITIALIZED), + transmission_start_ (ACE_Time_Value::zero), + transmission_end_ (ACE_Time_Value::zero) +{ + if (input_task_mgr_ == 0) + input_task_mgr_ = ACE_Thread_Manager::instance (); +} + +// Destructor. + +Bounded_Packet_Relay::~Bounded_Packet_Relay (void) +{ +} + +// Requests output be sent to output device. + +int +Bounded_Packet_Relay::send_input (void) +{ + // Don't block, return immediately if queue is empty. + ACE_Message_Block *item; + + // Using a separate (non-const) time value + // is necessary on some platforms + ACE_Time_Value immediate (ACE_Time_Value::zero); + + if (queue_.dequeue_head (item, + &immediate) < 0) + return 1; + + // If a message block was dequeued, send it to the output device. + + if (output_wrapper_->write_output_message ((void *) item) < 0) + ACE_ERROR_RETURN ((LM_ERROR, + "%t %p\n", + "failed to write to output device object"), + -1); + // If all went OK, increase count of packets sent. + ++packets_sent_; + return 0; +} + +// Requests a transmission be started. + +int +Bounded_Packet_Relay::start_transmission (u_long packet_count, + u_long arrival_period, + u_long logging_level) +{ + // Serialize access to start and end transmission calls, statistics + // reporting calls. + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1); + + // If a transmission is already in progress, just return. + if (status_ == STARTED) + return 1; + + // Update statistics for a new transmission. + ++transmission_number_; + packets_sent_ = 0; + status_ = STARTED; + transmission_start_ = ACE_OS::gettimeofday (); + + // Initialize the output device. + if (output_wrapper_->modify_device_settings ((void *) &logging_level) < 0) + { + status_ = ERROR_DETECTED; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "failed to initialize output device object"), + -1); + } + // Initialize the input device. + else if (input_wrapper_->set_input_period (arrival_period) < 0) + { + status_ = ERROR_DETECTED; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "failed to initialize input device object"), + -1); + } + else if (input_wrapper_->set_send_count (packet_count) < 0) + { + status_ = ERROR_DETECTED; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "failed to initialize input device object"), + -1); + } + // Activate the input device. + else if (input_wrapper_->activate () < 0) + { + status_ = ERROR_DETECTED; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "failed to activate input device object"), + -1); + } + + // If all went well, print a startup message and return success. + ACE_DEBUG ((LM_DEBUG, + "\n\nTransmission %u started\n\n", + transmission_number_)); + return 0; +} + +// Requests a transmission be ended. + +int +Bounded_Packet_Relay::end_transmission (Transmission_Status status) +{ + // Serialize access to start and end transmission calls, + // statistics reporting calls. + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1); + + // If a transmission is not already in progress, just return. + if (status_ != STARTED) + return 1; + + // Ask the the input thread to stop. + if (input_wrapper_->request_stop () < 0) + { + status_ = ERROR_DETECTED; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "failed asking input device thread to stop"), + -1); + } + + // Deactivate the queue, allowing all waiting threads to continue. + queue_.deactivate (); + + // Wait for input thread to stop. + if (input_task_mgr_->wait_task (input_wrapper_) < 0) + { + status_ = ERROR_DETECTED; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "failed waiting for input device thread to stop"), + -1); + } + + // Reactivate the queue, and then clear it. + queue_.activate (); + while (! queue_.is_empty ()) + { + ACE_Message_Block *msg; + queue_.dequeue_head (msg); + delete msg; + } + + // If all went well, set passed status, stamp end time, print a + // termination message, and return success. + status_ = status; + transmission_end_ = ACE_OS::gettimeofday (); + ACE_DEBUG ((LM_DEBUG, + "\n\nTransmission %u ended with status: %s\n\n", + transmission_number_, status_msg ())); + return 0; +} + +// Requests a report of statistics from the last transmission. + +int +Bounded_Packet_Relay::report_statistics (void) +{ + // Serialize access to start and end transmission calls, + // statistics reporting calls. + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1); + + // If a transmission is already in progress, just return. + if (status_ == STARTED) + return 1; + + // Calculate duration of trasmission. + ACE_Time_Value duration (transmission_end_); + duration -= transmission_start_; + + // Report transmission statistics. + ACE_DEBUG ((LM_DEBUG, + "\n\nStatisics for transmission %u:\n\n" + "Transmission status: %s\n" + "Start time: %d (sec) %d (usec)\n" + "End time: %d (sec) %d (usec)\n" + "Duration: %d (sec) %d (usec)\n" + "Packets relayed: %u\n\n", + transmission_number_, status_msg (), + transmission_start_.sec (), + transmission_start_.usec (), + transmission_end_.sec (), + transmission_end_.usec (), + duration.sec (), + duration.usec (), + packets_sent_)); + return 0; +} + +// Public entry point to which to push input. + +int +Bounded_Packet_Relay::receive_input (void * arg) +{ + ACE_Message_Block *message = ACE_static_cast (ACE_Message_Block *, + arg); + if (queue_.enqueue_tail (message) < 0) + ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", + "Bounded_Packet_Relay::receive_input failed"), + -1); + return 0; +} + +// Returns string corresponding to current status. + +const char * +Bounded_Packet_Relay::status_msg (void) +{ + const char *status_msg; + switch (status_) + { + case UN_INITIALIZED: + status_msg = "uninitialized"; + break; + case STARTED: + status_msg = "in progress"; + break; + case COMPLETED: + status_msg = "completed with all packets sent"; + break; + case TIMED_OUT: + status_msg = "terminated by transmission duration timer"; + break; + case CANCELLED: + status_msg = "cancelled by external control"; + break; + case ERROR_DETECTED: + status_msg = "error was detected"; + break; + default: + status_msg = "unknown transmission status"; + break; + } + + return status_msg; +} + diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers.h b/examples/Bounded_Packet_Relay/BPR_Drivers.h index 81e7197adf0..c480a376a8e 100644 --- a/examples/Bounded_Packet_Relay/BPR_Drivers.h +++ b/examples/Bounded_Packet_Relay/BPR_Drivers.h @@ -30,6 +30,7 @@ #define _BPR_DRIVERS_H_ #include "ace/Task.h" +#include "ace/Synch.h" // forward declarations class Input_Device_Wrapper_Base; @@ -50,14 +51,20 @@ public: // Invokes the method from the object . }; -class Bounded_Packet_Relay_Base +class Bounded_Packet_Relay { // = TITLE - // Base class for the time-bounded packet relay class. + // This class defines a packet relay abstraction for a + // transmission bounded external commands to start and end the + // transmission. The transmission may be bounded by the number + // of packets to send, the dration of the transmission, or any + // other factors. // // = DESCRIPTION - // This enum must go here to avoid confusing certain broken C++ - // compilers. + // The relay abstraction implemented by this class registers a + // callback command with an input device wrapper, and relays + // input to an output device at a pace specified in the start + // transmission call. public: // = Enumerates possible status values for a transmission. enum Transmission_Status @@ -69,6 +76,77 @@ public: CANCELLED, ERROR_DETECTED }; + + typedef int (Bounded_Packet_Relay::*ACTION) (void *); + // Command entry point type definition. + + // = Initialization method + + Bounded_Packet_Relay (ACE_Thread_Manager *input_task_mgr, + Input_Device_Wrapper_Base *input_wrapper, + Output_Device_Wrapper_Base *output_wrapper); + // Constructor. + + virtual ~Bounded_Packet_Relay (void); + // Destructor. + + int send_input (void); + // Requests output be sent to output device. + + int start_transmission (u_long packet_count, + u_long arrival_period, + u_long logging_level); + // Requests a transmission be started. + + int end_transmission (Transmission_Status status); + // Requests a transmission be ended. + + int report_statistics (void); + // Requests a report of statistics from the last transmission. + + // = Command Accessible Entry Points. + + int receive_input (void *); + // Public entry point to which to push input. + +private: + // = Concurrency Management. + + ACE_Thread_Manager * input_task_mgr_; + // Thread manager for the input device task. + + Input_Device_Wrapper_Base * input_wrapper_; + // Pointer to the input device wrapper. + + Output_Device_Wrapper_Base * output_wrapper_; + // Pointer to the output device wrapper. + + ACE_Message_Queue queue_; + // Queue used to buffer input messages. + + ACE_SYNCH_MUTEX transmission_lock_; + // Lock for thread-safe synchronization of transmission startup and + // termination. + + // = Transmission Statistics + + const char *status_msg (void); + // Returns string corresponding to current status. + + u_long transmission_number_; + // Number of transmissions sent. + + u_long packets_sent_; + // Count of packets sent in the most recent transmission. + + Transmission_Status status_; + // Status of the current or most recent transmission. + + ACE_Time_Value transmission_start_; + // Start time of the most recent transmission. + + ACE_Time_Value transmission_end_; + // Ending time of the most recent transmission. }; class Input_Device_Wrapper_Base : public ACE_Task_Base diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp b/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp index 35755941965..00e8cdc7a71 100644 --- a/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp +++ b/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp @@ -51,263 +51,6 @@ Command::execute (void *arg) } -// Constructor. - -template -Bounded_Packet_Relay::Bounded_Packet_Relay (ACE_Thread_Manager *input_task_mgr, - Input_Device_Wrapper_Base *input_wrapper, - Output_Device_Wrapper_Base *output_wrapper) - : input_task_mgr_ (input_task_mgr), - input_wrapper_ (input_wrapper), - output_wrapper_ (output_wrapper), - transmission_number_ (0), - packets_sent_ (0), - status_ (Bounded_Packet_Relay_Base::UN_INITIALIZED), - transmission_start_ (ACE_Time_Value::zero), - transmission_end_ (ACE_Time_Value::zero) -{ - if (input_task_mgr_ == 0) - input_task_mgr_ = ACE_Thread_Manager::instance (); -} - -// Destructor. - -template -Bounded_Packet_Relay::~Bounded_Packet_Relay (void) -{ -} - -// Requests output be sent to output device. - -template int -Bounded_Packet_Relay::send_input (void) -{ - // Don't block, return immediately if queue is empty. - ACE_Message_Block *item; - - // Using a separate (non-const) time value - // is necessary on some platforms - ACE_Time_Value immediate (ACE_Time_Value::zero); - - if (queue_.dequeue_head (item, - &immediate) < 0) - return 1; - - // If a message block was dequeued, send it to the output device. - - if (output_wrapper_->write_output_message ((void *) item) < 0) - ACE_ERROR_RETURN ((LM_ERROR, - "%t %p\n", - "failed to write to output device object"), - -1); - // If all went OK, increase count of packets sent. - ++packets_sent_; - return 0; -} - -// Requests a transmission be started. - -template int -Bounded_Packet_Relay::start_transmission (u_long packet_count, - u_long arrival_period, - u_long logging_level) -{ - // Serialize access to start and end transmission calls, statistics - // reporting calls. - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->transmission_lock_, -1); - - // If a transmission is already in progress, just return. - if (status_ == STARTED) - return 1; - - // Update statistics for a new transmission. - ++transmission_number_; - packets_sent_ = 0; - status_ = STARTED; - transmission_start_ = ACE_OS::gettimeofday (); - - // Initialize the output device. - if (output_wrapper_->modify_device_settings ((void *) &logging_level) < 0) - { - status_ = ERROR_DETECTED; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "failed to initialize output device object"), - -1); - } - // Initialize the input device. - else if (input_wrapper_->set_input_period (arrival_period) < 0) - { - status_ = ERROR_DETECTED; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "failed to initialize input device object"), - -1); - } - else if (input_wrapper_->set_send_count (packet_count) < 0) - { - status_ = ERROR_DETECTED; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "failed to initialize input device object"), - -1); - } - // Activate the input device. - else if (input_wrapper_->activate () < 0) - { - status_ = ERROR_DETECTED; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "failed to activate input device object"), - -1); - } - - // If all went well, print a startup message and return success. - ACE_DEBUG ((LM_DEBUG, - "\n\nTransmission %u started\n\n", - transmission_number_)); - return 0; -} - -// Requests a transmission be ended. - -template int -Bounded_Packet_Relay::end_transmission (Transmission_Status status) -{ - // Serialize access to start and end transmission calls, - // statistics reporting calls. - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->transmission_lock_, -1); - - // If a transmission is not already in progress, just return. - if (status_ != STARTED) - return 1; - - // Ask the the input thread to stop. - if (input_wrapper_->request_stop () < 0) - { - status_ = ERROR_DETECTED; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "failed asking input device thread to stop"), - -1); - } - - // Deactivate the queue, allowing all waiting threads to continue. - queue_.deactivate (); - - // Wait for input thread to stop. - if (input_task_mgr_->wait_task (input_wrapper_) < 0) - { - status_ = ERROR_DETECTED; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "failed waiting for input device thread to stop"), - -1); - } - - // Reactivate the queue, and then clear it. - queue_.activate (); - while (! queue_.is_empty ()) - { - ACE_Message_Block *msg; - queue_.dequeue_head (msg); - delete msg; - } - - // If all went well, set passed status, stamp end time, print a - // termination message, and return success. - status_ = status; - transmission_end_ = ACE_OS::gettimeofday (); - ACE_DEBUG ((LM_DEBUG, - "\n\nTransmission %u ended with status: %s\n\n", - transmission_number_, status_msg ())); - return 0; -} - -// Requests a report of statistics from the last transmission. - -template int -Bounded_Packet_Relay::report_statistics (void) -{ - // Serialize access to start and end transmission calls, - // statistics reporting calls. - ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->transmission_lock_, -1); - - // If a transmission is already in progress, just return. - if (status_ == STARTED) - return 1; - - // Calculate duration of trasmission. - ACE_Time_Value duration (transmission_end_); - duration -= transmission_start_; - - // Report transmission statistics. - ACE_DEBUG ((LM_DEBUG, - "\n\nStatisics for transmission %u:\n\n" - "Transmission status: %s\n" - "Start time: %d (sec) %d (usec)\n" - "End time: %d (sec) %d (usec)\n" - "Duration: %d (sec) %d (usec)\n" - "Packets relayed: %u\n\n", - transmission_number_, status_msg (), - transmission_start_.sec (), - transmission_start_.usec (), - transmission_end_.sec (), - transmission_end_.usec (), - duration.sec (), - duration.usec (), - packets_sent_)); - return 0; -} - -// Public entry point to which to push input. - -template int -Bounded_Packet_Relay::receive_input (void * arg) -{ - ACE_Message_Block *message = ACE_static_cast (ACE_Message_Block *, - arg); - if (queue_.enqueue_tail (message) < 0) - ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n", - "Bounded_Packet_Relay::receive_input failed"), - -1); - return 0; -} - -// Returns string corresponding to current status. - -template const char * -Bounded_Packet_Relay::status_msg () -{ - const char *status_msg; - switch (status_) - { - case UN_INITIALIZED: - status_msg = "uninitialized"; - break; - case STARTED: - status_msg = "in progress"; - break; - case COMPLETED: - status_msg = "completed with all packets sent"; - break; - case TIMED_OUT: - status_msg = "terminated by transmission duration timer"; - break; - case CANCELLED: - status_msg = "cancelled by external control"; - break; - case ERROR_DETECTED: - status_msg = "error was detected"; - break; - default: - status_msg = "unknown transmission status"; - break; - } - - return status_msg; -} - // Constructor. template diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers_T.h b/examples/Bounded_Packet_Relay/BPR_Drivers_T.h index 2a4bd2de9db..f91d6b23b1e 100644 --- a/examples/Bounded_Packet_Relay/BPR_Drivers_T.h +++ b/examples/Bounded_Packet_Relay/BPR_Drivers_T.h @@ -29,7 +29,7 @@ #if !defined (_BPR_DRIVERS_T_H_) #define _BPR_DRIVERS_T_H_ -// forward declarations +// Forward declarations. class Input_Device_Wrapper_Base; class Output_Device_Wrapper_Base; @@ -63,95 +63,6 @@ private: // Method that is going to be invoked. }; -template -class Bounded_Packet_Relay : public Bounded_Packet_Relay_Base -{ - // = TITLE - // This class defines a packet relay abstraction for a - // transmission bounded external commands to start and end the - // transmission. The transmission may be bounded by the number - // of packets to send, the dration of the transmission, or any - // other factors. - // - // = DESCRIPTION - // The relay abstraction implemented by this class registers a - // callback command with an input device wrapper, and relays - // input to an output device at a pace specified in the start - // transmission call. -public: - typedef int (Bounded_Packet_Relay::*ACTION) (void *); - // Command entry point type definition. - - // = Initialization method - - Bounded_Packet_Relay (ACE_Thread_Manager *input_task_mgr, - Input_Device_Wrapper_Base *input_wrapper, - Output_Device_Wrapper_Base *output_wrapper); - // Constructor. - - virtual ~Bounded_Packet_Relay (void); - // Destructor. - - int send_input (void); - // Requests output be sent to output device. - - int start_transmission (u_long packet_count, - u_long arrival_period, - u_long logging_level); - // Requests a transmission be started. - - int end_transmission (Transmission_Status status); - // Requests a transmission be ended. - - int report_statistics (void); - // Requests a report of statistics from the last transmission. - - // = Command Accessible Entry Points. - - int receive_input (void *); - // Public entry point to which to push input. - -private: - // = Concurrency Management. - - ACE_Thread_Manager * input_task_mgr_; - // Thread manager for the input device task. - - Input_Device_Wrapper_Base * input_wrapper_; - // Pointer to the input device wrapper. - - Output_Device_Wrapper_Base * output_wrapper_; - // Pointer to the output device wrapper. - - ACE_Message_Queue queue_; - // Queue used to buffer input messages. - - ACE_SYNCH_MUTEX_T transmission_lock_; - // Lock for thread-safe synchronization - // of transmission startup and termination. - - // = Transmission Statistics - - const char * status_msg (void); - // Returns string corresponding to current status. - - u_long transmission_number_; - // Number of transmissions sent. - - u_long packets_sent_; - // Count of packets sent in the most recent transmission. - - Transmission_Status status_; - // Status of the current or most recent transmission. - - ACE_Time_Value transmission_start_; - // Start time of the most recent transmission. - - ACE_Time_Value transmission_end_; - // Ending time of the most recent transmission. - -}; - template class Bounded_Packet_Relay_Driver { diff --git a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp index f52d886369b..d21cb6b935d 100644 --- a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp +++ b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp @@ -131,7 +131,7 @@ Text_Output_Device_Wrapper::modify_device_settings (void *logging) // Constructor. -User_Input_Task::User_Input_Task (Bounded_Packet_Relay *relay, +User_Input_Task::User_Input_Task (Bounded_Packet_Relay *relay, Thread_Timer_Queue *queue, Thread_Bounded_Packet_Relay_Driver &tbprd) : ACE_Task_Base (ACE_Thread_Manager::instance ()), @@ -154,7 +154,7 @@ User_Input_Task::svc (void) break; // We are done. - this->relay_->end_transmission (Bounded_Packet_Relay_Base::CANCELLED); + this->relay_->end_transmission (Bounded_Packet_Relay::CANCELLED); this->queue_->deactivate (); ACE_DEBUG ((LM_DEBUG, "terminating user input thread\n")); @@ -314,7 +314,7 @@ User_Input_Task::end_transmission (void *) { if (relay_) { - switch (relay_->end_transmission (Bounded_Packet_Relay_Base::CANCELLED)) + switch (relay_->end_transmission (Bounded_Packet_Relay::CANCELLED)) { case 1: ACE_DEBUG ((LM_DEBUG, @@ -402,7 +402,7 @@ User_Input_Task::clear_all_timers (void) // Constructor. -BPR_Handler_Base::BPR_Handler_Base (Bounded_Packet_Relay &relay, +BPR_Handler_Base::BPR_Handler_Base (Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue) : relay_ (relay), queue_ (queue) @@ -434,7 +434,7 @@ BPR_Handler_Base::clear_all_timers (void) Send_Handler::Send_Handler (u_long send_count, const ACE_Time_Value &duration, - Bounded_Packet_Relay &relay, + Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue) : BPR_Handler_Base (relay, queue), send_count_ (send_count), @@ -478,7 +478,7 @@ Send_Handler::handle_timeout (const ACE_Time_Value ¤t_time, // All packets are sent, time to cancel any other timers, // end the transmission, and go away. this->clear_all_timers (); - relay_.end_transmission (Bounded_Packet_Relay_Base::COMPLETED); + relay_.end_transmission (Bounded_Packet_Relay::COMPLETED); delete this; return 0; } @@ -499,7 +499,7 @@ Send_Handler::cancelled (void) // Constructor. -Termination_Handler::Termination_Handler (Bounded_Packet_Relay &relay, +Termination_Handler::Termination_Handler (Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue) : BPR_Handler_Base (relay, queue) { @@ -520,7 +520,7 @@ Termination_Handler::handle_timeout (const ACE_Time_Value ¤t_time, // Transmission timed out, so cancel any other // timers, end the transmission, and go away. this->clear_all_timers (); - relay_.end_transmission (Bounded_Packet_Relay_Base::TIMED_OUT); + relay_.end_transmission (Bounded_Packet_Relay::TIMED_OUT); delete this; return 0; } @@ -536,7 +536,7 @@ Termination_Handler::cancelled (void) // Constructor. -Thread_Bounded_Packet_Relay_Driver::Thread_Bounded_Packet_Relay_Driver (Bounded_Packet_Relay *relay) +Thread_Bounded_Packet_Relay_Driver::Thread_Bounded_Packet_Relay_Driver (Bounded_Packet_Relay *relay) : input_task_ (relay, &timer_queue_, *this) { } diff --git a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h index 44687aab80d..84af9fa33dc 100644 --- a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h +++ b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h @@ -136,7 +136,7 @@ public: typedef int (User_Input_Task::*ACTION) (void *); // Trait for command accessible entry points. - User_Input_Task (Bounded_Packet_Relay *relay, + User_Input_Task (Bounded_Packet_Relay *relay, Thread_Timer_Queue *queue, Thread_Bounded_Packet_Relay_Driver &timer_queue_driver); // Constructor. @@ -184,7 +184,7 @@ private: const int usecs_; // How many microseconds are in a second. - Bounded_Packet_Relay *relay_; + Bounded_Packet_Relay *relay_; // The bounded packet relay. Thread_Timer_Queue *queue_; @@ -206,8 +206,8 @@ class BPR_Handler_Base : public ACE_Event_Handler // with the timer queue. Otherwise it calls the relay's end // transmission method, clears the timer queue, and then deletes "this". public: - BPR_Handler_Base (Bounded_Packet_Relay &relay, - Thread_Timer_Queue &queue); + BPR_Handler_Base (Bounded_Packet_Relay &relay, + Thread_Timer_Queue &queue); // Constructor. ~BPR_Handler_Base (void); @@ -217,7 +217,7 @@ public: // Helper method: clears all timers. protected: - Bounded_Packet_Relay &relay_; + Bounded_Packet_Relay &relay_; // Stores a reference to the relay object on which to invoke // the appropritate calls when the timer expires. @@ -240,7 +240,7 @@ class Send_Handler : public BPR_Handler_Base public: Send_Handler (u_long send_count, const ACE_Time_Value &duration, - Bounded_Packet_Relay &relay, + Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue); // Constructor. @@ -273,7 +273,7 @@ class Termination_Handler : public BPR_Handler_Base // The hook method calls the relay's end // transmission method, and then deletes "this". public: - Termination_Handler (Bounded_Packet_Relay &relay, + Termination_Handler (Bounded_Packet_Relay &relay, Thread_Timer_Queue &queue); // Constructor. @@ -304,7 +304,7 @@ public: typedef Command COMMAND; // = Initialization and termination methods. - Thread_Bounded_Packet_Relay_Driver (Bounded_Packet_Relay *relay); + Thread_Bounded_Packet_Relay_Driver (Bounded_Packet_Relay *relay); // Constructor. ~Thread_Bounded_Packet_Relay_Driver (void); diff --git a/examples/Bounded_Packet_Relay/bpr_thread.cpp b/examples/Bounded_Packet_Relay/bpr_thread.cpp index d5982c14d86..ba950343c66 100644 --- a/examples/Bounded_Packet_Relay/bpr_thread.cpp +++ b/examples/Bounded_Packet_Relay/bpr_thread.cpp @@ -31,10 +31,7 @@ ACE_RCSID(Bounded_Packet_Relay, bpr_thread, "$Id$") typedef Bounded_Packet_Relay_Driver THREAD_BOUNDED_PACKET_RELAY_DRIVER; -typedef Bounded_Packet_Relay - BOUNDED_PACKET_RELAY; - -typedef Command +typedef Command INPUT_CALLBACK; // A snippet from Andrew Marvell (Oliver Cromwell's poet laureate) @@ -73,13 +70,13 @@ main (int, char *[]) // Construct a new bounded packet relay. Auto ptr ensures memory is // freed when we exit this scope. - BOUNDED_PACKET_RELAY *packet_relay; + Bounded_Packet_Relay *packet_relay; ACE_NEW_RETURN (packet_relay, - BOUNDED_PACKET_RELAY (input_task_mgr, + Bounded_Packet_Relay (input_task_mgr, input_device, output_device), -1); - auto_ptr relay (packet_relay); + auto_ptr relay (packet_relay); // Construct a receive input callback command for the relay, and register // it with the input device. Auto ptr ensures memory is freed when we exit @@ -87,7 +84,7 @@ main (int, char *[]) INPUT_CALLBACK *input_callback; ACE_NEW_RETURN (input_callback, INPUT_CALLBACK (*packet_relay, - &BOUNDED_PACKET_RELAY::receive_input), + &Bounded_Packet_Relay::receive_input), -1); auto_ptr callback (input_callback); if (input_device->set_send_input_msg_cmd (input_callback) < 0) -- cgit v1.2.1