xrootd
XrdClPollerBuiltIn.hh
Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
00003 // Author: Lukasz Janyst <ljanyst@cern.ch>
00004 //------------------------------------------------------------------------------
00005 // XRootD is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // XRootD is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
00017 //------------------------------------------------------------------------------
00018 
00019 #ifndef __XRD_CL_POLLER_BUILT_IN_HH__
00020 #define __XRD_CL_POLLER_BUILT_IN_HH__
00021 
00022 #include "XrdSys/XrdSysPthread.hh"
00023 #include "XrdCl/XrdClPoller.hh"
00024 #include <map>
00025 
00026 namespace XrdSys { namespace IOEvents
00027 {
00028   class Poller;
00029 }; };
00030 
00031 namespace XrdCl
00032 {
00033   //----------------------------------------------------------------------------
00035   //----------------------------------------------------------------------------
00036   class PollerBuiltIn: public Poller
00037   {
00038     public:
00039       //------------------------------------------------------------------------
00041       //------------------------------------------------------------------------
00042       PollerBuiltIn(): pPoller( 0 ) {}
00043 
00044       //------------------------------------------------------------------------
00046       //------------------------------------------------------------------------
00047       virtual bool Initialize();
00048 
00049       //------------------------------------------------------------------------
00051       //------------------------------------------------------------------------
00052       virtual bool Finalize();
00053 
00054       //------------------------------------------------------------------------
00056       //------------------------------------------------------------------------
00057       virtual bool Start();
00058 
00059       //------------------------------------------------------------------------
00061       //------------------------------------------------------------------------
00062       virtual bool Stop();
00063 
00064       //------------------------------------------------------------------------
00069       //------------------------------------------------------------------------
00070       virtual bool AddSocket( Socket        *socket,
00071                               SocketHandler *handler );
00072 
00073 
00074       //------------------------------------------------------------------------
00076       //------------------------------------------------------------------------
00077       virtual bool RemoveSocket( Socket *socket );
00078 
00079       //------------------------------------------------------------------------
00086       //------------------------------------------------------------------------
00087       virtual bool EnableReadNotification( Socket  *socket,
00088                                            bool     notify,
00089                                            uint16_t timeout = 60 );
00090 
00091       //------------------------------------------------------------------------
00098       //------------------------------------------------------------------------
00099       virtual bool EnableWriteNotification( Socket  *socket,
00100                                             bool     notify,
00101                                             uint16_t timeout = 60);
00102 
00103       //------------------------------------------------------------------------
00105       //------------------------------------------------------------------------
00106       virtual bool IsRegistered( Socket *socket );
00107 
00108       //------------------------------------------------------------------------
00110       //------------------------------------------------------------------------
00111       virtual bool IsRunning() const
00112       {
00113         return pPoller;
00114       }
00115 
00116     private:
00117       typedef std::map<Socket *, void *> SocketMap;
00118       SocketMap                 pSocketMap;
00119       XrdSys::IOEvents::Poller *pPoller;
00120       XrdSysMutex pMutex;
00121   };
00122 }
00123 
00124 #endif // __XRD_CL_POLLER_BUILT_IN_HH__