summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorcdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-23 01:53:51 +0000
committercdgill <cdgill@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-23 01:53:51 +0000
commita3f7c33a86dec7f2f4aa362e5f35c51cfd6eb903 (patch)
treec9b910c77a30b8faecd301b4adf2bf742413f89a /examples
parent16042ee425923ae65212b527dc783a97db134569 (diff)
downloadATCD-a3f7c33a86dec7f2f4aa362e5f35c51cfd6eb903.tar.gz
more packet relay example fixes
Diffstat (limited to 'examples')
-rw-r--r--examples/Bounded_Packet_Relay/BPR_Drivers.cpp149
-rw-r--r--examples/Bounded_Packet_Relay/BPR_Drivers.h9
-rw-r--r--examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp23
-rw-r--r--examples/Bounded_Packet_Relay/BPR_Drivers_T.h6
-rw-r--r--examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp108
-rw-r--r--examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h45
-rw-r--r--examples/Bounded_Packet_Relay/bpr_thread.cpp2
7 files changed, 252 insertions, 90 deletions
diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers.cpp b/examples/Bounded_Packet_Relay/BPR_Drivers.cpp
index 27f70fb4a33..ac39349cb2b 100644
--- a/examples/Bounded_Packet_Relay/BPR_Drivers.cpp
+++ b/examples/Bounded_Packet_Relay/BPR_Drivers.cpp
@@ -106,33 +106,49 @@ Input_Device_Wrapper_Base::svc (void)
(is_active_) && (current_count_ != 0);
)
{
- // Make sure there is a send command object.
- if (send_input_msg_cmd_ == 0)
- {
- is_active_ = 0;
- ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
- "send message command object not instantiated"),
- -1);
- }
-
// Create an input message to send.
message = create_input_message ();
if (message == 0)
{
- is_active_ = 0;
- ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
- "Failed to create input message object"),
- -1);
+ if (is_active_)
+ {
+ is_active_ = 0;
+ ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
+ "Failed to create input message object"),
+ -1);
+ }
+
+ break;
+ }
+
+ // Make sure there is a send command object.
+ if (send_input_msg_cmd_ == 0)
+ {
+ if (is_active_)
+ {
+ is_active_ = 0;
+ delete message;
+ ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
+ "send message command object not instantiated"),
+ -1);
+ }
+
+ break;
}
// Send the input message.
if (send_input_msg_cmd_->execute ((void *) message) < 0)
{
- is_active_ = 0;
- delete message;
- ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
- "Failed executing send message command object"),
- -1);
+ if (is_active_)
+ {
+ is_active_ = 0;
+ delete message;
+ ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
+ "Failed executing send message command object"),
+ -1);
+ }
+
+ break;
}
// If all went well, decrement count of messages to send, and
@@ -160,10 +176,14 @@ Input_Device_Wrapper_Base::send_input_message (ACE_Message_Block *amb)
if (send_input_msg_cmd_)
return send_input_msg_cmd_->execute ((void *) amb);
else
- ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
- "Input_Device_Wrapper_Base::send_input_message: "
- "command object not instantiated"),
- -1);
+ {
+ if (is_active_)
+ ACE_ERROR ((LM_ERROR, "%t %p\n",
+ "Input_Device_Wrapper_Base::send_input_message: "
+ "command object not instantiated"));
+
+ return -1;
+ }
}
// Constructor.
@@ -171,7 +191,8 @@ Input_Device_Wrapper_Base::send_input_message (ACE_Message_Block *amb)
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),
+ : is_active_ (0),
+ input_task_mgr_ (input_task_mgr),
input_wrapper_ (input_wrapper),
output_wrapper_ (output_wrapper),
transmission_number_ (0),
@@ -209,10 +230,15 @@ Bounded_Packet_Relay::send_input (void)
// 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 (is_active_)
+ ACE_ERROR ((LM_ERROR,
+ "%t %p\n",
+ "failed to write to output device object"));
+
+ return -1;
+ }
+
// If all went OK, increase count of packets sent.
++packets_sent_;
return 0;
@@ -222,16 +248,19 @@ Bounded_Packet_Relay::send_input (void)
int
Bounded_Packet_Relay::start_transmission (u_long packet_count,
- u_long arrival_period,
- u_long logging_level)
+ u_long arrival_period,
+ int 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)
+ if (is_active_)
return 1;
+
+ // Set transmission in progress flag true.
+ is_active_ = 1;
// Update statistics for a new transmission.
++transmission_number_;
@@ -239,20 +268,40 @@ Bounded_Packet_Relay::start_transmission (u_long packet_count,
status_ = STARTED;
transmission_start_ = ACE_OS::gettimeofday ();
+ // Reactivate the queue, and then clear it.
+ queue_.activate ();
+ while (! queue_.is_empty ())
+ {
+ ACE_Message_Block *msg;
+ queue_.dequeue_head (msg);
+ delete msg;
+ }
+
// Initialize the output device.
if (output_wrapper_->modify_device_settings ((void *) &logging_level) < 0)
{
status_ = ERROR_DETECTED;
transmission_end_ = ACE_OS::gettimeofday ();
+ is_active_ = 0;
ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
"failed to initialize output device object"),
-1);
}
// Initialize the input device.
+ if (input_wrapper_->modify_device_settings ((void *) &logging_level) < 0)
+ {
+ status_ = ERROR_DETECTED;
+ transmission_end_ = ACE_OS::gettimeofday ();
+ is_active_ = 0;
+ ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
+ "failed to initialize output device object"),
+ -1);
+ }
else if (input_wrapper_->set_input_period (arrival_period) < 0)
{
status_ = ERROR_DETECTED;
transmission_end_ = ACE_OS::gettimeofday ();
+ is_active_ = 0;
ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
"failed to initialize input device object"),
-1);
@@ -261,6 +310,7 @@ Bounded_Packet_Relay::start_transmission (u_long packet_count,
{
status_ = ERROR_DETECTED;
transmission_end_ = ACE_OS::gettimeofday ();
+ is_active_ = 0;
ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
"failed to initialize input device object"),
-1);
@@ -270,6 +320,7 @@ Bounded_Packet_Relay::start_transmission (u_long packet_count,
{
status_ = ERROR_DETECTED;
transmission_end_ = ACE_OS::gettimeofday ();
+ is_active_ = 0;
ACE_ERROR_RETURN ((LM_ERROR, "%t %p\n",
"failed to activate input device object"),
-1);
@@ -292,8 +343,11 @@ Bounded_Packet_Relay::end_transmission (Transmission_Status status)
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)
+ if (! is_active_)
return 1;
+
+ // Set transmission in progress flag false.
+ is_active_ = 0;
// Ask the the input thread to stop.
if (input_wrapper_->request_stop () < 0)
@@ -309,14 +363,7 @@ Bounded_Packet_Relay::end_transmission (Transmission_Status status)
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);
- }
+ input_task_mgr_->wait_task (input_wrapper_);
// Reactivate the queue, and then clear it.
queue_.activate ();
@@ -347,9 +394,9 @@ Bounded_Packet_Relay::report_statistics (void)
ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->transmission_lock_, -1);
// If a transmission is already in progress, just return.
- if (status_ == STARTED)
+ if (is_active_)
return 1;
-
+
// Calculate duration of trasmission.
ACE_Time_Value duration (transmission_end_);
duration -= transmission_start_;
@@ -378,12 +425,26 @@ Bounded_Packet_Relay::report_statistics (void)
int
Bounded_Packet_Relay::receive_input (void * arg)
{
+ if (! arg)
+ {
+ if (is_active_)
+ ACE_ERROR ((LM_ERROR, "%t %p\n",
+ "Bounded_Packet_Relay::receive_input: "
+ "null argument"));
+
+ return -1;
+ }
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);
+ {
+ if (is_active_)
+ ACE_ERROR ((LM_ERROR, "%t %p\n",
+ "Bounded_Packet_Relay::receive_input failed"));
+
+ return -1;
+ }
+
return 0;
}
diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers.h b/examples/Bounded_Packet_Relay/BPR_Drivers.h
index c480a376a8e..4c21d882b32 100644
--- a/examples/Bounded_Packet_Relay/BPR_Drivers.h
+++ b/examples/Bounded_Packet_Relay/BPR_Drivers.h
@@ -95,7 +95,7 @@ public:
int start_transmission (u_long packet_count,
u_long arrival_period,
- u_long logging_level);
+ int logging_level);
// Requests a transmission be started.
int end_transmission (Transmission_Status status);
@@ -112,6 +112,9 @@ public:
private:
// = Concurrency Management.
+ int is_active_;
+ // flag for whether or not a transmission is active
+
ACE_Thread_Manager * input_task_mgr_;
// Thread manager for the input device task.
@@ -200,6 +203,10 @@ public:
virtual int svc (void);
// This method runs the input device loop in the new thread.
+ virtual int modify_device_settings (void *) = 0;
+ // Provides an abstract interface to allow modifying device
+ // settings.
+
protected:
virtual ACE_Message_Block *create_input_message (void) = 0;
// Creates a new message block, carrying data read from the
diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp b/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp
index 00e8cdc7a71..5b19fd1b4d5 100644
--- a/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp
+++ b/examples/Bounded_Packet_Relay/BPR_Drivers_T.cpp
@@ -141,20 +141,24 @@ Bounded_Packet_Relay_Driver<TQ>::parse_commands (const char *buf)
if (duration_limit_cmd_->execute ((void *) &usec) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%t %p\n",
- "set duration limit failed"),
+ "\nSet duration limit failed."),
-1);
break;
}
case 5: // Set logging level.
{
- u_long level;
+ int level;
// We just reread the option, this simplies parsing (since
// sscanf can do it for us).
- if (::sscanf (buf, "%d %lu", &option, &level) < 2)
- // If there was not enough information on the line, ignore
- // option and try the next line.
- return 0;
+ if ((::sscanf (buf, "%d %d", &option, &level) < 2) ||
+ (level < 0) || (level > 7))
+ {
+ // If there was not enough information on the line, or the
+ // passed value was invalid, ignore and try again.
+ return 0;
+ }
+
if (logging_level_cmd_->execute ((void *) &level) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"%t %p\n",
@@ -208,9 +212,6 @@ Bounded_Packet_Relay_Driver<TQ>::get_next_request (void)
this->display_menu ();
- ACE_DEBUG ((LM_DEBUG,
- "Please enter your choice: "));
-
// Reads input from the user.
if (this->read_input (buf, sizeof buf) <= 0)
return -1;
@@ -296,7 +297,7 @@ Bounded_Packet_Relay_Driver<TQ>::duration_limit (u_long dl)
}
// Get logging level.
-template <class TQ> u_long
+template <class TQ> int
Bounded_Packet_Relay_Driver<TQ>::logging_level (void)
{
return logging_level_;
@@ -305,7 +306,7 @@ Bounded_Packet_Relay_Driver<TQ>::logging_level (void)
// Set logging level.
template <class TQ> void
-Bounded_Packet_Relay_Driver<TQ>::logging_level (u_long ll)
+Bounded_Packet_Relay_Driver<TQ>::logging_level (int ll)
{
logging_level_ = ll;
}
diff --git a/examples/Bounded_Packet_Relay/BPR_Drivers_T.h b/examples/Bounded_Packet_Relay/BPR_Drivers_T.h
index f91d6b23b1e..436b444ad2e 100644
--- a/examples/Bounded_Packet_Relay/BPR_Drivers_T.h
+++ b/examples/Bounded_Packet_Relay/BPR_Drivers_T.h
@@ -130,10 +130,10 @@ public:
void duration_limit (u_long dl);
// Set limit on the duration of the transmission (usec).
- u_long logging_level (void);
+ int logging_level (void);
// Get logging level.
- void logging_level (u_long ll);
+ void logging_level (int ll);
// Set logging level.
protected:
@@ -184,7 +184,7 @@ private:
u_long duration_limit_;
// Limit on the duration of the transmission (usec).
- u_long logging_level_;
+ int logging_level_;
// Logging level.
};
diff --git a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp
index d21cb6b935d..eb0ec7fd81e 100644
--- a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp
+++ b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.cpp
@@ -36,11 +36,15 @@ ACE_RCSID(Bounded_Packet_Relay, Thread_Bounded_Packet_Relay, "$Id$")
Text_Input_Device_Wrapper::Text_Input_Device_Wrapper (ACE_Thread_Manager *input_task_mgr,
size_t read_length,
- const char* text)
+ const char* text,
+ int logging)
: Input_Device_Wrapper_Base (input_task_mgr),
read_length_ (read_length),
text_ (text),
- index_ (0)
+ index_ (0),
+ logging_ (logging),
+ packet_count_ (0)
+
{
}
@@ -50,6 +54,24 @@ Text_Input_Device_Wrapper::~Text_Input_Device_Wrapper (void)
{
}
+// Modifies device settings based on passed pointer to a u_long.
+
+int
+Text_Input_Device_Wrapper::modify_device_settings (void *logging)
+{
+ packet_count_ = 0;
+
+ if (logging)
+ logging_ = *ACE_static_cast (int *, logging);
+ else
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Text_Input_Device_Wrapper::modify_device_settings: "
+ "null argument"),
+ -1);
+ return 0;
+}
+
+
// Creates a new message block, carrying data
// read from the underlying input device.
@@ -83,6 +105,15 @@ Text_Input_Device_Wrapper::create_input_message (void)
"read buffer copy failed"),
0);
}
+
+ // log packet creation if logging is turned on
+ if (logging_ & Text_Input_Device_Wrapper::LOG_MSGS_CREATED)
+ {
+ ++packet_count_;
+ ACE_DEBUG ((LM_DEBUG, "input message %d created\n",
+ packet_count_));
+ }
+
return mb;
}
@@ -100,10 +131,18 @@ Text_Output_Device_Wrapper::write_output_message (void *message)
{
if (message)
{
- if (logging_)
- ACE_DEBUG ((LM_DEBUG, "%s",
+ ++packet_count_;
+
+ if (logging_ & Text_Output_Device_Wrapper::LOG_MSGS_RCVD)
+ ACE_DEBUG ((LM_DEBUG, "output message %d received\n",
+ packet_count_));
+
+ if (logging_ & Text_Output_Device_Wrapper::PRINT_MSGS_RCVD)
+ ACE_DEBUG ((LM_DEBUG, "output message %d:\n[%s]\n",
+ packet_count_,
ACE_static_cast (ACE_Message_Block *, message)->
- rd_ptr ()));
+ rd_ptr ()));
+
delete ACE_static_cast (ACE_Message_Block *,
message);
return 0;
@@ -113,18 +152,19 @@ Text_Output_Device_Wrapper::write_output_message (void *message)
"write_output_message: null argument"), -1);
}
-// Modifies device settings based on passed pointer to a u_long turns
-// logging on if u_long is non-zero, off if u_long is zero, and does
-// nothing if the pointer is null.
+// Modifies device settings based on passed pointer to a u_long.
int
Text_Output_Device_Wrapper::modify_device_settings (void *logging)
{
+ packet_count_ = 0;
+
if (logging)
logging_ = *ACE_static_cast (int *, logging);
else
ACE_ERROR_RETURN ((LM_ERROR,
- "null logging level pointer"),
+ "Text_Output_Device_Wrapper::modify_device_settings: "
+ "null argument"),
-1);
return 0;
}
@@ -267,7 +307,8 @@ User_Input_Task::run_transmission (void *)
Send_Handler (driver_.packet_count (),
send_every,
*relay_,
- *queue_),
+ *queue_,
+ driver_),
-1);
if (queue_->schedule (send_handler, 0, send_at) < 0)
ACE_ERROR_RETURN ((LM_ERROR,
@@ -283,7 +324,8 @@ User_Input_Task::run_transmission (void *)
ACE_NEW_RETURN (termination_handler,
Termination_Handler (*relay_,
- *queue_),
+ *queue_,
+ driver_),
-1);
if (queue_->schedule (termination_handler,
0, terminate_at) < 0)
@@ -435,10 +477,12 @@ BPR_Handler_Base::clear_all_timers (void)
Send_Handler::Send_Handler (u_long send_count,
const ACE_Time_Value &duration,
Bounded_Packet_Relay &relay,
- Thread_Timer_Queue &queue)
+ Thread_Timer_Queue &queue,
+ Thread_Bounded_Packet_Relay_Driver &driver)
: BPR_Handler_Base (relay, queue),
send_count_ (send_count),
- duration_ (duration)
+ duration_ (duration),
+ driver_ (driver)
{
}
@@ -475,10 +519,11 @@ Send_Handler::handle_timeout (const ACE_Time_Value &current_time,
}
else
{
- // All packets are sent, time to cancel any other timers,
- // end the transmission, and go away.
+ // All packets are sent, time to cancel any other timers, end
+ // the transmission, redisplay the user menu, and go away.
this->clear_all_timers ();
relay_.end_transmission (Bounded_Packet_Relay::COMPLETED);
+ driver_.display_menu ();
delete this;
return 0;
}
@@ -500,8 +545,10 @@ Send_Handler::cancelled (void)
// Constructor.
Termination_Handler::Termination_Handler (Bounded_Packet_Relay &relay,
- Thread_Timer_Queue &queue)
- : BPR_Handler_Base (relay, queue)
+ Thread_Timer_Queue &queue,
+ Thread_Bounded_Packet_Relay_Driver &driver)
+ : BPR_Handler_Base (relay, queue),
+ driver_ (driver)
{
}
@@ -517,10 +564,11 @@ int
Termination_Handler::handle_timeout (const ACE_Time_Value &current_time,
const void *arg)
{
- // Transmission timed out, so cancel any other
- // timers, end the transmission, and go away.
+ // Transmission timed out, so cancel any other timers,
+ // end the transmission, display the user menu, and go away.
this->clear_all_timers ();
relay_.end_transmission (Bounded_Packet_Relay::TIMED_OUT);
+ driver_.display_menu ();
delete this;
return 0;
}
@@ -563,14 +611,22 @@ Thread_Bounded_Packet_Relay_Driver::display_menu (void)
" min = 1.\n"
" 4 <limit on duration of transmission (in usec) = %d>\n"
" min = 1, no limit = 0.\n"
- " 5 <logging level = %d>\n"
- " no logging = 0, logging = non-zero.\n"
+ " 5 <logging level flags = %d>\n"
+ " no logging = 0,\n"
+ " log packets created by input device = 1,\n"
+ " log packets consumed by output device = 2,\n"
+ " logging options 1,2 = 3,\n"
+ " print contents of packets consumed by output put device = 4,\n"
+ " logging options 1,4 = 5,\n"
+ " logging options 2,4 = 6,\n"
+ " logging options 1,2,4 = 7.\n"
+ " ----------------------------------------------------------------------\n"
+ " 6 - runs a transmission using the current settings\n"
+ " 7 - cancels a transmission (if there is one running)\n"
+ " 8 - reports statistics from the most recent transmission\n"
+ " 9 - quits the program\n"
" ----------------------------------------------------------------------\n"
- " 6 - run a transmission using the current settings\n"
- " 7 - cancel transmission (if there is one running)\n"
- " 8 - report statistics from the most recent transmission\n"
- " 9 - quit the program\n"
- " ----------------------------------------------------------------------\n";
+ " Please enter your choice: ";
ACE_DEBUG ((LM_DEBUG,
menu,
diff --git a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h
index 84af9fa33dc..b53b3f0d8a9 100644
--- a/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h
+++ b/examples/Bounded_Packet_Relay/Thread_Bounded_Packet_Relay.h
@@ -70,15 +70,26 @@ class Text_Input_Device_Wrapper : public Input_Device_Wrapper_Base
// streams. Comments to this effect appear in the definition of
// the event loop method.
public:
+
+ // = Enumerated logging level flags
+ enum Logging_Flags {NO_LOGGING = 0,
+ LOG_MSGS_CREATED = 1};
+
// = Initialization and termination methods.
Text_Input_Device_Wrapper (ACE_Thread_Manager *input_task_mgr,
size_t read_length,
- const char* text);
+ const char* text,
+ int logging = 0);
// Constructor.
~Text_Input_Device_Wrapper (void);
// Destructor.
+ virtual int modify_device_settings (void *logging);
+ // Modifies device settings based on passed pointer to a u_long.
+ // Turns logging on if u_long is non-zero, off if u_long is zero,
+ // and does nothing if the pointer is null.
+
protected:
virtual ACE_Message_Block *create_input_message (void);
// Creates a new message block, carrying data read from the
@@ -93,6 +104,13 @@ private:
size_t index_;
// Index into the string.
+
+ int logging_;
+ // This value is 0 if logging is turned off, non-zero otherwise
+
+ u_long packet_count_;
+ // This value holds a count of packets created.
+
};
class Text_Output_Device_Wrapper : public Output_Device_Wrapper_Base
@@ -105,6 +123,11 @@ class Text_Output_Device_Wrapper : public Output_Device_Wrapper_Base
// output stream, if logging is turned on.
public:
+ // = Enumerated logging level flags
+ enum Logging_Flags {NO_LOGGING = 0,
+ LOG_MSGS_RCVD = 2,
+ PRINT_MSGS_RCVD = 4};
+
Text_Output_Device_Wrapper (int logging = 0);
// Default constructor.
@@ -119,8 +142,13 @@ public:
// and does nothing if the pointer is null.
private:
+
int logging_;
- // This value is 0 if logging is turned off, non-zero otherwise
+ // This value holds the logging level.
+
+ u_long packet_count_;
+ // This value holds a count of packets received.
+
};
class User_Input_Task : public ACE_Task_Base
@@ -241,7 +269,8 @@ public:
Send_Handler (u_long send_count,
const ACE_Time_Value &duration,
Bounded_Packet_Relay &relay,
- Thread_Timer_Queue &queue);
+ Thread_Timer_Queue &queue,
+ Thread_Bounded_Packet_Relay_Driver &driver);
// Constructor.
~Send_Handler (void);
@@ -262,6 +291,9 @@ private:
ACE_Time_Value duration_;
// Stores the expected duration until expiration, and is used to
// re-register the handler if there are still sends to perform.
+
+ Thread_Bounded_Packet_Relay_Driver &driver_;
+ // Reference to the driver that will redisplay the user input menu.
};
class Termination_Handler : public BPR_Handler_Base
@@ -274,7 +306,8 @@ class Termination_Handler : public BPR_Handler_Base
// transmission method, and then deletes "this".
public:
Termination_Handler (Bounded_Packet_Relay &relay,
- Thread_Timer_Queue &queue);
+ Thread_Timer_Queue &queue,
+ Thread_Bounded_Packet_Relay_Driver &driver);
// Constructor.
~Termination_Handler (void);
@@ -286,6 +319,10 @@ public:
virtual int cancelled (void);
// Cancellation hook.
+
+private:
+ Thread_Bounded_Packet_Relay_Driver &driver_;
+ // Reference to the driver that will redisplay the user input menu.
};
class Thread_Bounded_Packet_Relay_Driver : public Bounded_Packet_Relay_Driver <Thread_Timer_Queue>
diff --git a/examples/Bounded_Packet_Relay/bpr_thread.cpp b/examples/Bounded_Packet_Relay/bpr_thread.cpp
index ba950343c66..ea232893d62 100644
--- a/examples/Bounded_Packet_Relay/bpr_thread.cpp
+++ b/examples/Bounded_Packet_Relay/bpr_thread.cpp
@@ -37,7 +37,7 @@ typedef Command<Bounded_Packet_Relay, Bounded_Packet_Relay::ACTION>
// A snippet from Andrew Marvell (Oliver Cromwell's poet laureate)
static const char input_text [] =
"But ever at my back I hear\n"
-"Time's winged chariot hurrying near.\n";
+" Time's winged chariot hurrying near.";
int
main (int, char *[])