xrootd
XrdClOutQueue.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __XRD_CL_OUT_QUEUE_HH__
20 #define __XRD_CL_OUT_QUEUE_HH__
21 
22 #include <list>
23 #include <utility>
24 #include "XrdCl/XrdClStatus.hh"
25 
26 namespace XrdCl
27 {
28  class Message;
29  class OutgoingMsgHandler;
30 
31  //----------------------------------------------------------------------------
33  //----------------------------------------------------------------------------
34  class OutQueue
35  {
36  public:
37  //------------------------------------------------------------------------
47  //------------------------------------------------------------------------
48  void PushBack( Message *msg,
49  OutgoingMsgHandler *handler,
50  time_t expires,
51  bool stateful );
52 
53  //------------------------------------------------------------------------
63  //------------------------------------------------------------------------
64  void PushFront( Message *msg,
65  OutgoingMsgHandler *handler,
66  time_t expires,
67  bool stateful );
68 
69  //------------------------------------------------------------------------
73  //------------------------------------------------------------------------
75  time_t &expires,
76  bool &stateful );
77 
78  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  void PopFront();
82 
83  //------------------------------------------------------------------------
85  //------------------------------------------------------------------------
86  void Report( Status status );
87 
88  //------------------------------------------------------------------------
90  //------------------------------------------------------------------------
91  bool IsEmpty() const
92  {
93  return pMessages.empty();
94  }
95 
96  //------------------------------------------------------------------------
97  // Return the size of the queue
98  //------------------------------------------------------------------------
99  uint64_t GetSize() const
100  {
101  return pMessages.size();
102  }
103 
104  //------------------------------------------------------------------------
106  //------------------------------------------------------------------------
107  uint64_t GetSizeStateless() const;
108 
109  //------------------------------------------------------------------------
115  //------------------------------------------------------------------------
116  void GrabExpired( OutQueue &queue, time_t exp = 0 );
117 
118  //------------------------------------------------------------------------
123  //------------------------------------------------------------------------
124  void GrabStateful( OutQueue &queue );
125 
126  //------------------------------------------------------------------------
130  //------------------------------------------------------------------------
131  void GrabItems( OutQueue &queue );
132 
133  private:
134  //------------------------------------------------------------------------
135  // Helper struct holding all the message data
136  //------------------------------------------------------------------------
137  struct MsgHelper
138  {
139  MsgHelper( Message *m, OutgoingMsgHandler *h, time_t r, bool s ):
140  msg( m ), handler( h ), expires( r ), stateful( s ) {}
141 
144  time_t expires;
145  bool stateful;
146  };
147 
148  typedef std::list<MsgHelper> MessageList;
150  };
151 }
152 
153 #endif // __XRD_CL_OUT_QUEUE_HH__