00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef QUEUEDRETURN_H
00016 #define QUEUEDRETURN_H
00017
00018 #include "pandabase.h"
00019
00020 #include "connectionListener.h"
00021 #include "connection.h"
00022 #include "netAddress.h"
00023 #include "lightMutex.h"
00024 #include "pdeque.h"
00025 #include "config_net.h"
00026 #include "lightMutexHolder.h"
00027
00028 #include <algorithm>
00029
00030
00031
00032
00033
00034
00035
00036
00037 template<class Thing>
00038 class QueuedReturn {
00039 PUBLISHED:
00040 void set_max_queue_size(int max_size);
00041 int get_max_queue_size() const;
00042 int get_current_queue_size() const;
00043
00044 bool get_overflow_flag() const;
00045 void reset_overflow_flag();
00046
00047 protected:
00048 QueuedReturn();
00049 ~QueuedReturn();
00050
00051 INLINE bool thing_available() const;
00052 bool get_thing(Thing &thing);
00053
00054 bool enqueue_thing(const Thing &thing);
00055 bool enqueue_unique_thing(const Thing &thing);
00056
00057 private:
00058 LightMutex _mutex;
00059 pdeque<Thing> _things;
00060 bool _available;
00061 int _max_queue_size;
00062 bool _overflow_flag;
00063 };
00064
00065 #include "queuedReturn.I"
00066
00067 #endif
00068