xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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 #include "XrdSys/XrdSysPthread.hh"
27 
28 namespace XrdCl
29 {
30  class Message;
31  class OutgoingMsgHandler;
32 
33  //----------------------------------------------------------------------------
35  //----------------------------------------------------------------------------
36  class OutQueue
37  {
38  public:
39  //------------------------------------------------------------------------
49  //------------------------------------------------------------------------
50  void PushBack( Message *msg,
51  OutgoingMsgHandler *handler,
52  time_t expires,
53  bool stateful );
54 
55  //------------------------------------------------------------------------
65  //------------------------------------------------------------------------
66  void PushFront( Message *msg,
67  OutgoingMsgHandler *handler,
68  time_t expires,
69  bool stateful );
70 
71  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
77  time_t &expires,
78  bool &stateful );
79 
80  //------------------------------------------------------------------------
82  //------------------------------------------------------------------------
83  void PopFront();
84 
85  //------------------------------------------------------------------------
87  //------------------------------------------------------------------------
88  void Report( Status status );
89 
90  //------------------------------------------------------------------------
92  //------------------------------------------------------------------------
93  bool IsEmpty() const
94  {
95  return pMessages.empty();
96  }
97 
98  //------------------------------------------------------------------------
99  // Return the size of the queue
100  //------------------------------------------------------------------------
101  uint64_t GetSize() const
102  {
103  return pMessages.size();
104  }
105 
106  //------------------------------------------------------------------------
108  //------------------------------------------------------------------------
109  uint64_t GetSizeStateless() const;
110 
111  //------------------------------------------------------------------------
117  //------------------------------------------------------------------------
118  void GrabExpired( OutQueue &queue, time_t exp = 0 );
119 
120  //------------------------------------------------------------------------
125  //------------------------------------------------------------------------
126  void GrabStateful( OutQueue &queue );
127 
128  //------------------------------------------------------------------------
132  //------------------------------------------------------------------------
133  void GrabItems( OutQueue &queue );
134 
135  private:
136  //------------------------------------------------------------------------
137  // Helper struct holding all the message data
138  //------------------------------------------------------------------------
139  struct MsgHelper
140  {
141  MsgHelper( Message *m, OutgoingMsgHandler *h, time_t r, bool s ):
142  msg( m ), handler( h ), expires( r ), stateful( s ) {}
143 
146  time_t expires;
147  bool stateful;
148  };
149 
150  typedef std::list<MsgHelper> MessageList;
153 
154  };
155 }
156 
157 #endif // __XRD_CL_OUT_QUEUE_HH__
void Report(Status status)
Report status to all the handlers.
void PushBack(Message *msg, OutgoingMsgHandler *handler, time_t expires, bool stateful)
void PushFront(Message *msg, OutgoingMsgHandler *handler, time_t expires, bool stateful)
Message * PopMessage(OutgoingMsgHandler *&handler, time_t &expires, bool &stateful)
bool stateful
Definition: XrdClOutQueue.hh:147
std::list< MsgHelper > MessageList
Definition: XrdClOutQueue.hh:150
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
void GrabItems(OutQueue &queue)
time_t expires
Definition: XrdClOutQueue.hh:146
Procedure execution status.
Definition: XrdClStatus.hh:109
XrdSysMutex pMutex
Definition: XrdClOutQueue.hh:152
Message * msg
Definition: XrdClOutQueue.hh:144
Definition: XrdSysPthread.hh:165
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)
OutgoingMsgHandler * handler
Definition: XrdClOutQueue.hh:145
A synchronized queue for the outgoing data.
Definition: XrdClOutQueue.hh:36
MessageList pMessages
Definition: XrdClOutQueue.hh:151
uint64_t GetSize() const
Definition: XrdClOutQueue.hh:101
Definition: XrdClOutQueue.hh:139
bool IsEmpty() const
Check if the queue is empty.
Definition: XrdClOutQueue.hh:93
Message status handler.
Definition: XrdClPostMasterInterfaces.hh:167
void PopFront()
Remove a message from the front.
MsgHelper(Message *m, OutgoingMsgHandler *h, time_t r, bool s)
Definition: XrdClOutQueue.hh:141