xrootd
XrdClForkHandler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 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_FORK_HANDLER_HH__
20 #define __XRD_CL_FORK_HANDLER_HH__
21 
22 #include <XrdSys/XrdSysPthread.hh>
23 #include <set>
24 
25 namespace XrdCl
26 {
27  class FileStateHandler;
28  class FileSystem;
29  class PostMaster;
30 
31  //----------------------------------------------------------------------------
32  // Helper class for handling forking
33  //----------------------------------------------------------------------------
35  {
36  public:
37  ForkHandler();
38 
39  //------------------------------------------------------------------------
41  //------------------------------------------------------------------------
43  {
44  XrdSysMutexHelper scopedLock( pMutex );
45  pFileObjects.insert( file );
46  }
47 
48  //------------------------------------------------------------------------
49  // Un-register a file object
50  //------------------------------------------------------------------------
52  {
53  XrdSysMutexHelper scopedLock( pMutex );
54  pFileObjects.erase( file );
55  }
56 
57  //------------------------------------------------------------------------
58  // Register a file system object
59  //------------------------------------------------------------------------
61  {
62  XrdSysMutexHelper scopedLock( pMutex );
63  pFileSystemObjects.insert( fs );
64  }
65 
66  //------------------------------------------------------------------------
68  //------------------------------------------------------------------------
70  {
71  XrdSysMutexHelper scopedLock( pMutex );
72  pFileSystemObjects.erase( fs );
73  }
74 
75  //------------------------------------------------------------------------
77  //------------------------------------------------------------------------
78  void RegisterPostMaster( PostMaster *postMaster )
79  {
80  XrdSysMutexHelper scopedLock( pMutex );
81  pPostMaster = postMaster;
82  }
83 
84  //------------------------------------------------------------------------
86  //------------------------------------------------------------------------
87  void Prepare();
88 
89  //------------------------------------------------------------------------
91  //------------------------------------------------------------------------
92  void Parent();
93 
94  //------------------------------------------------------------------------
96  //------------------------------------------------------------------------
97  void Child();
98 
99  private:
100  std::set<FileStateHandler*> pFileObjects;
101  std::set<FileSystem*> pFileSystemObjects;
104  };
105 }
106 
107 #endif // __XRD_CL_FORK_HANDLER_HH__