xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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>
25 
26 namespace XrdCl
27 {
28  class Message;
29  class MsgHandler;
30 
31  //----------------------------------------------------------------------------
33  //----------------------------------------------------------------------------
34  class OutQueue
35  {
36  public:
37  //------------------------------------------------------------------------
47  //------------------------------------------------------------------------
48  void PushBack( Message *msg,
49  MsgHandler *handler,
50  time_t expires,
51  bool stateful );
52 
53  //------------------------------------------------------------------------
63  //------------------------------------------------------------------------
64  void PushFront( Message *msg,
65  MsgHandler *handler,
66  time_t expires,
67  bool stateful );
68 
69  //------------------------------------------------------------------------
73  //------------------------------------------------------------------------
74  Message *PopMessage( MsgHandler *&handler,
75  time_t &expires,
76  bool &stateful );
77 
78  //------------------------------------------------------------------------
80  //------------------------------------------------------------------------
81  void PopFront();
82 
83  //------------------------------------------------------------------------
85  //------------------------------------------------------------------------
86  void Report( XRootDStatus 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  //------------------------------------------------------------------------
134  // Helper struct holding all the message data
135  //------------------------------------------------------------------------
136  struct MsgHelper
137  {
138  MsgHelper( Message *m = nullptr, MsgHandler *h = nullptr, time_t r = 0, bool s = false ):
139  msg( m ), handler( h ), expires( r ), stateful( s ) {}
140 
141  void Reset()
142  {
143  msg = 0; handler = 0; expires = 0; stateful = 0;
144  }
145 
148  time_t expires;
149  bool stateful;
150  };
151 
152  private:
153 
154  typedef std::list<MsgHelper> MessageList;
156  };
157 }
158 
159 #endif // __XRD_CL_OUT_QUEUE_HH__
void Reset()
Definition: XrdClOutQueue.hh:141
bool stateful
Definition: XrdClOutQueue.hh:149
std::list< MsgHelper > MessageList
Definition: XrdClOutQueue.hh:154
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
void GrabItems(OutQueue &queue)
Message handler.
Definition: XrdClPostMasterInterfaces.hh:50
void Report(XRootDStatus status)
Report status to all the handlers.
time_t expires
Definition: XrdClOutQueue.hh:148
Message * msg
Definition: XrdClOutQueue.hh:146
Message * PopMessage(MsgHandler *&handler, time_t &expires, bool &stateful)
void PushFront(Message *msg, MsgHandler *handler, time_t expires, bool stateful)
void GrabExpired(OutQueue &queue, time_t exp=0)
uint64_t GetSizeStateless() const
Return the size of the queue counting only the stateless messages.
void GrabStateful(OutQueue &queue)
Request status.
Definition: XrdClXRootDResponses.hh:218
A synchronized queue for the outgoing data.
Definition: XrdClOutQueue.hh:34
MessageList pMessages
Definition: XrdClOutQueue.hh:155
MsgHandler * handler
Definition: XrdClOutQueue.hh:147
uint64_t GetSize() const
Definition: XrdClOutQueue.hh:99
void PushBack(Message *msg, MsgHandler *handler, time_t expires, bool stateful)
Definition: XrdClOutQueue.hh:136
bool IsEmpty() const
Check if the queue is empty.
Definition: XrdClOutQueue.hh:91
MsgHelper(Message *m=nullptr, MsgHandler *h=nullptr, time_t r=0, bool s=false)
Definition: XrdClOutQueue.hh:138
void PopFront()
Remove a message from the front.