Vault
4.1
|
00001 /* 00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved. 00003 This file is part of the Code Vault version 4.1 00004 http://www.bombaydigital.com/ 00005 License: MIT. See LICENSE.md in the Vault top level directory. 00006 */ 00007 00008 #ifndef vmessagequeue_h 00009 #define vmessagequeue_h 00010 00011 #include "vtypes.h" 00012 #include "vmutex.h" 00013 #include "vsemaphore.h" 00014 #include "vcompactingdeque.h" 00015 #include "vmessage.h" 00016 00036 class VMessageQueue { 00037 public: 00038 00042 VMessageQueue(); 00046 virtual ~VMessageQueue(); 00047 00054 virtual void postMessage(VMessagePtr message); 00061 VMessagePtr blockUntilNextMessage(); 00068 VMessagePtr getNextMessage(); 00075 void wakeUp(); 00080 VSizeType getQueueSize() const; 00085 Vs64 getQueueDataSize() const; 00089 void releaseAllMessages(); 00090 00098 static void setQueueingLagLoggingThreshold(const VDuration& threshold) { gVMessageQueueLagLoggingThreshold = threshold; } 00099 static VDuration getQueueingLagLoggingThreshold() { return gVMessageQueueLagLoggingThreshold; } 00100 static void setQueueingLagLoggingLevel(int logLevel) { gVMessageQueueLagLoggingLevel = logLevel; } 00101 static int getQueueingLagLoggingLevel() { return gVMessageQueueLagLoggingLevel; } 00102 00103 private: 00104 00105 VCompactingDeque<VMessagePtr> mQueuedMessages; 00106 Vs64 mQueuedMessagesDataSize; 00107 VMutex mMessageQueueMutex; 00108 VSemaphore mMessageQueueSemaphore; 00109 VInstant mLastMessagePostTime; 00110 00111 static VDuration gVMessageQueueLagLoggingThreshold; 00112 static int gVMessageQueueLagLoggingLevel; 00113 }; 00114 00115 #endif /* vmessagequeue_h */