MessageTracker.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef OPENDDS_DCPS_MESSAGETRACKER_H
00009 #define OPENDDS_DCPS_MESSAGETRACKER_H
00010 
00011 #include <dds/DCPS/dcps_export.h>
00012 #include <ace/Thread_Mutex.h>
00013 #include <ace/Condition_Thread_Mutex.h>
00014 
00015 #include "dds/DCPS/PoolAllocator.h"
00016 
00017 namespace OpenDDS {
00018 namespace DCPS {
00019 
00020   /**
00021    * A simple message tracker to use to wait until all messages have been
00022    * accounted for being continuing processing.
00023    */
00024   class OpenDDS_Dcps_Export MessageTracker {
00025   public:
00026     MessageTracker(const OPENDDS_STRING& msg_src);
00027 
00028     /**
00029      * Indicate that a message has been to the transport layer.
00030      */
00031     void message_sent();
00032 
00033     /**
00034      * Indicate that a message has been delivered by the transport layer.
00035      */
00036     void message_delivered();
00037 
00038     /**
00039      * Indicate that a message has been dropped by the transport layer.
00040      */
00041     void message_dropped();
00042 
00043     /**
00044      * Answer if there are any messages that have not been accounted for.
00045      */
00046     bool pending_messages();
00047 
00048     /**
00049      * Block until all messages have been account for.
00050      */
00051     void wait_messages_pending(OPENDDS_STRING& caller_message);
00052 
00053     /**
00054      * Provide a timestamp for the passed in time.
00055      * DEPRECATED: remove and replace with ACE::timestamp
00056      * once TAO 1.6a is no longer supported
00057      */
00058     static ACE_TCHAR*
00059     timestamp (const ACE_Time_Value& time_value,
00060                ACE_TCHAR date_and_time[],
00061                size_t date_and_timelen);
00062 
00063     /**
00064      * For testing.
00065      */
00066     int dropped_count();
00067 
00068   private:
00069 
00070     const OPENDDS_STRING msg_src_;         // Source of tracked messages
00071     int                  dropped_count_;
00072     int                  delivered_count_; // Messages transmitted by transport layer
00073     int                  sent_count_;      // Messages sent to transport layer
00074 
00075     ACE_Thread_Mutex lock_;
00076 
00077     /// All messages have been transported condition variable.
00078     ACE_Condition_Thread_Mutex done_condition_;
00079 
00080   };
00081 
00082 } // namespace DCPS
00083 } // namespace OpenDDS
00084 
00085 
00086 #endif
00087 

Generated on Fri Feb 12 20:05:24 2016 for OpenDDS by  doxygen 1.4.7