XRootD
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 <memory>
25 #include <utility>
28 
29 namespace XrdCl
30 {
31  class Message;
32 
33  //----------------------------------------------------------------------------
35  //----------------------------------------------------------------------------
36  class InQueue
37  {
38  public:
39  //------------------------------------------------------------------------
46  //------------------------------------------------------------------------
47  void AddMessageHandler( MsgHandler *handler, time_t expires, bool &rmMsg );
48 
49  //------------------------------------------------------------------------
58  //------------------------------------------------------------------------
59  MsgHandler *GetHandlerForMessage( std::shared_ptr<Message> &msg,
60  time_t &expires,
61  uint16_t &action );
62 
63  //------------------------------------------------------------------------
65  //------------------------------------------------------------------------
66  void ReAddMessageHandler( MsgHandler *handler, time_t expires );
67 
68  //------------------------------------------------------------------------
70  //------------------------------------------------------------------------
71  void RemoveMessageHandler( MsgHandler *handler );
72 
73  //------------------------------------------------------------------------
75  //------------------------------------------------------------------------
77  XRootDStatus status );
78 
79  //------------------------------------------------------------------------
81  //------------------------------------------------------------------------
82  void ReportTimeout( time_t now = 0 );
83 
84  private:
85 
86  //------------------------------------------------------------------------
95  //------------------------------------------------------------------------
96  bool DiscardMessage(Message& msg, uint16_t& sid) const;
97 
98  typedef std::pair<MsgHandler *, time_t> HandlerAndExpire;
99  typedef std::map<uint16_t, HandlerAndExpire> HandlerMap;
100  HandlerMap pHandlers;
101  XrdSysRecMutex pMutex;
102  };
103 }
104 
105 #endif // __XRD_CL_IN_QUEUE_HH__
A synchronize queue for incoming data.
Definition: XrdClInQueue.hh:37
void ReportTimeout(time_t now=0)
Timeout handlers.
void RemoveMessageHandler(MsgHandler *handler)
Remove a listener.
void ReAddMessageHandler(MsgHandler *handler, time_t expires)
Re-insert the handler without scanning the cached messages.
void ReportStreamEvent(MsgHandler::StreamEvent event, XRootDStatus status)
Report an event to the handlers.
MsgHandler * GetHandlerForMessage(std::shared_ptr< Message > &msg, time_t &expires, uint16_t &action)
Definition: XrdClInQueue.cc:66
void AddMessageHandler(MsgHandler *handler, time_t expires, bool &rmMsg)
Definition: XrdClInQueue.cc:54
The message representation used throughout the system.
Definition: XrdClMessage.hh:32
StreamEvent
Events that may have occurred to the stream.