00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "ScheduleOutputHandler.h"
00010
00011 #include "TransportSendStrategy.h"
00012
00013 #if !defined (__ACE_INLINE__)
00014 #include "ScheduleOutputHandler.inl"
00015 #endif
00016
00017 void
00018 OpenDDS::DCPS::ScheduleOutputHandler::schedule_output()
00019 {
00020 DBG_ENTRY_LVL("ScheduleOutputHandler","schedule_output",6);
00021
00022
00023
00024 if( reference_count_ == 1) {
00025
00026 TransportSendStrategy::SendMode mode = strategy_->mode();
00027
00028 if( ( (state_ == Enabled) && (mode == TransportSendStrategy::MODE_DIRECT))
00029 || ( (state_ == Disabled) && ( (mode == TransportSendStrategy::MODE_QUEUE)
00030 || (mode == TransportSendStrategy::MODE_SUSPEND)))) {
00031 reactor()->notify(this);
00032 }
00033 }
00034 }
00035
00036 int
00037 OpenDDS::DCPS::ScheduleOutputHandler::handle_exception(ACE_HANDLE)
00038 {
00039 DBG_ENTRY_LVL("ScheduleOutputHandler","handle_exception",6);
00040
00041 if( reference_count_ == 1) {
00042
00043
00044 return -1;
00045 }
00046
00047
00048
00049
00050
00051
00052
00053 TransportSendStrategy::SendMode mode = strategy_->mode();
00054 bool changed = false;
00055
00056 ACE_HANDLE handle = strategy_->get_handle();
00057
00058 if( mode == TransportSendStrategy::MODE_DIRECT) {
00059
00060 if( state_ == Enabled) {
00061 reactor()->cancel_wakeup(handle, ACE_Event_Handler::WRITE_MASK);
00062 state_ = Disabled;
00063 changed = true;
00064 }
00065
00066 } else if( (mode == TransportSendStrategy::MODE_QUEUE)
00067 || (mode == TransportSendStrategy::MODE_SUSPEND)) {
00068
00069
00070 if( state_ == Disabled) {
00071 reactor()->schedule_wakeup(handle, ACE_Event_Handler::WRITE_MASK);
00072 state_ = Enabled;
00073 changed = true;
00074 }
00075 }
00076
00077 if (DCPS_debug_level > 4) {
00078 ACE_DEBUG((LM_DEBUG,
00079 ACE_TEXT("(%P|%t) ScheduleOutputHandler::handle_exception() - [%d] ")
00080 ACE_TEXT("%C data queueing for handle %d.\n"),
00081 strategy_->id(),
00082 (changed? ((state_ == Enabled)? "starting": "canceling"): "declining to change"),
00083 handle));
00084 }
00085
00086
00087
00088 return -1;
00089 }
00090