Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[modules/kernel.git] / src / SALOMEDS / SALOMEDS.hxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //
23 //
24 //  File   : SALOMEDS.hxx
25 //  Author : Sergey ANIKIN
26 //  Module : SALOME
27 //  $Header$
28
29
30 #ifndef SALOMEDS_HeaderFile
31 #define SALOMEDS_HeaderFile
32
33 #include <SALOMEDS_Defines.hxx>
34
35 #include <Utils_Mutex.hxx>
36
37 namespace SALOMEDS
38 {
39   // PAL8065: san -- Implementation of convenient locker based on simple recursive 
40   // mutex for POSIX platforms.
41   // This class is to protect SALOMEDS CORBA methods which deal with OCC calls from 
42   // parallel access by several threads
43   // To protect some method, an instance of Locker class should be created
44   // on the stack at the beginning of guarded code:
45   //
46   //    Locker lock;
47   //
48   class SALOMEDS_EXPORT Locker : public Utils_Locker
49   {
50   public:
51     Locker();
52     virtual ~Locker();
53
54   private:
55     static Utils_Mutex MutexDS;
56
57     friend void lock();
58     friend void unlock();
59   };
60
61   // Convenient functions to lock/unlock the global SALOMEDS mutex temporarily.
62   // In particular, "unlock-dosomething-lock" scheme should be used, when some non-SALOMEDS
63   // CORBA interface is called (component's engine), to avoid deadlocks in case of 
64   // indirect recursion.
65   void lock();
66   void unlock();
67 };
68
69 #endif