xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XrdClInQueue.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_IN_QUEUE_HH__
20 #define __XRD_CL_IN_QUEUE_HH__
21 
22 #include <XrdSys/XrdSysPthread.hh>
23 #include <map>
24 #include <utility>
27 
28 namespace XrdCl
29 {
30  class Message;
31 
32  //----------------------------------------------------------------------------
34  //----------------------------------------------------------------------------
35  class InQueue
36  {
37  public:
38  //------------------------------------------------------------------------
40  //------------------------------------------------------------------------
41  bool AddMessage( Message *msg );
42 
43  //------------------------------------------------------------------------
50  //------------------------------------------------------------------------
51  void AddMessageHandler( MsgHandler *handler, time_t expires, bool &rmMsg );
52 
53  //------------------------------------------------------------------------
62  //------------------------------------------------------------------------
64  time_t &expires,
65  uint16_t &action );
66 
67  //------------------------------------------------------------------------
69  //------------------------------------------------------------------------
70  void ReAddMessageHandler( MsgHandler *handler, time_t expires );
71 
72  //------------------------------------------------------------------------
74  //------------------------------------------------------------------------
75  void RemoveMessageHandler( MsgHandler *handler );
76 
77  //------------------------------------------------------------------------
79  //------------------------------------------------------------------------
81  XRootDStatus status );
82 
83  //------------------------------------------------------------------------
85  //------------------------------------------------------------------------
86  void ReportTimeout( time_t now = 0 );
87 
88  private:
89 
90  //------------------------------------------------------------------------
99  //------------------------------------------------------------------------
100  bool DiscardMessage(Message* msg, uint16_t& sid) const;
101 
102  typedef std::pair<MsgHandler *, time_t> HandlerAndExpire;
103  typedef std::map<uint16_t, HandlerAndExpire> HandlerMap;
104  typedef std::map<uint16_t, Message*> MessageMap;
108  };
109 }
110 
111 #endif // __XRD_CL_IN_QUEUE_HH__
bool DiscardMessage(Message *msg, uint16_t &sid) const
Definition: XrdSysPthread.hh:241
The message representation used throughout the system.
Definition: XrdClMessage.hh:29
void AddMessageHandler(MsgHandler *handler, time_t expires, bool &rmMsg)
std::pair< MsgHandler *, time_t > HandlerAndExpire
Definition: XrdClInQueue.hh:102
Message handler.
Definition: XrdClPostMasterInterfaces.hh:49
void ReportStreamEvent(MsgHandler::StreamEvent event, XRootDStatus status)
Report an event to the handlers.
StreamEvent
Events that may have occurred to the stream.
Definition: XrdClPostMasterInterfaces.hh:76
void ReportTimeout(time_t now=0)
Timeout handlers.
HandlerMap pHandlers
Definition: XrdClInQueue.hh:106
MessageMap pMessages
Definition: XrdClInQueue.hh:105
std::map< uint16_t, Message * > MessageMap
Definition: XrdClInQueue.hh:104
Request status.
Definition: XrdClXRootDResponses.hh:218
A synchronize queue for incoming data.
Definition: XrdClInQueue.hh:35
MsgHandler * GetHandlerForMessage(Message *msg, time_t &expires, uint16_t &action)
void RemoveMessageHandler(MsgHandler *handler)
Remove a listener.
bool AddMessage(Message *msg)
Add a fully reconstructed message to the queue.
std::map< uint16_t, HandlerAndExpire > HandlerMap
Definition: XrdClInQueue.hh:103
XrdSysRecMutex pMutex
Definition: XrdClInQueue.hh:107
void ReAddMessageHandler(MsgHandler *handler, time_t expires)
Re-insert the handler without scanning the cached messages.