0029935: Foundation Classes - introduce OSD_ThreadPool class defining a thread pool
[occt.git] / src / OSD / OSD.hxx
CommitLineData
42cf5bc1 1// Copyright (c) 1992-1999 Matra Datavision
2// Copyright (c) 1999-2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _OSD_HeaderFile
16#define _OSD_HeaderFile
17
18#include <Standard.hxx>
19#include <Standard_DefineAlloc.hxx>
20#include <Standard_Handle.hxx>
21
22#include <Standard_Boolean.hxx>
23#include <Standard_Integer.hxx>
24#include <Standard_Real.hxx>
25#include <Standard_PCharacter.hxx>
26#include <Standard_CString.hxx>
27class OSD_Error;
28class OSD_Protection;
29class OSD_Path;
30class OSD_FileNode;
31class OSD_Disk;
32class OSD_File;
33class OSD_FileIterator;
34class OSD_Directory;
35class OSD_DirectoryIterator;
42cf5bc1 36class OSD_Timer;
42cf5bc1 37class OSD_Host;
38class OSD_Environment;
39class OSD_EnvironmentIterator;
40class OSD_Process;
41class OSD_SharedLibrary;
42class OSD_Thread;
43
44
45//! Set of Operating Sytem Dependent Tools
46//! (O)perating (S)ystem (D)ependent
47class OSD
48{
49public:
50
51 DEFINE_STANDARD_ALLOC
52
53
42cf5bc1 54 //! Sets signal and exception handlers.
cb728702 55 //!
56 //! ### Windows-specific notes
57 //!
42cf5bc1 58 //! Compiled with MS VC++ sets 3 main handlers:
59 //! @li Signal handlers (via ::signal() functions) that translate system signals
60 //! (SIGSEGV, SIGFPE, SIGILL) into C++ exceptions (classes inheriting
61 //! Standard_Failure). They only be called if user calls ::raise() function
62 //! with one of supported signal type set.
63 //! @li Exception handler OSD::WntHandler() (via ::SetUnhandledExceptionFilter())
64 //! that will be used when user's code is compiled with /EHs option.
65 //! @li Structured exception (SE) translator (via _set_se_translator()) that
66 //! translates SE exceptions (aka asynchronous exceptions) into the
67 //! C++ exceptions inheriting Standard_Failure. This translator will be
68 //! used when user's code is compiled with /EHa option.
69 //!
70 //! This approach ensures that regardless of the option the user chooses to
71 //! compile his code with (/EHs or /EHa), signals (or SE exceptions) will be
72 //! translated into Open CASCADE C++ exceptions.
73 //!
74 //! If @a theFloatingSignal is TRUE then floating point exceptions will be
75 //! generated in accordance with the mask
cb728702 76 //! <tt>_EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW</tt> that is
42cf5bc1 77 //! used to call ::_controlfp() system function. If @a theFloatingSignal is FALSE
78 //! corresponding operations (e.g. division by zero) will gracefully complete
79 //! without an exception.
80 //!
cb728702 81 //! ### Unix-specific notes
82 //!
42cf5bc1 83 //! OSD::SetSignal() sets handlers (via ::sigaction()) for multiple signals
84 //! (SIGFPE, SIGSEGV, etc). Currently the number of handled signals is much
85 //! greater than for Windows, in the future this may change to provide better
86 //! consistency with Windows.
87 //!
88 //! @a theFloatingSignal is recognized on Sun Solaris, Linux, and SGI Irix to
89 //! generate floating-point exception according to the mask
90 //! <tt>FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW</tt> (in Linux conventions).<br>
91 //! When compiled with OBJS macro defined, already set signal handlers (e.g.
92 //! by Data Base Managers) are not redefined.
93 //!
cb728702 94 //! ### Common notes
95 //!
42cf5bc1 96 //! If OSD::SetSignal() method is used in at least one thread, it must also be
97 //! called in any other thread where Open CASCADE will be used, to ensure
98 //! consistency of behavior. Its @a aFloatingSignal argument must be consistent
99 //! across threads.
100 //!
101 //! Keep in mind that whether the C++ exception will really be thrown (i.e.
9775fa61 102 //! ::throw() will be called) is regulated by the
103 //! OCC_CONVERT_SIGNALS macro used during compilation of Open CASCADE and
42cf5bc1 104 //! user's code. Refer to Foundation Classes User's Guide for further details.
cb728702 105 //!
42cf5bc1 106 Standard_EXPORT static void SetSignal (const Standard_Boolean theFloatingSignal = Standard_True);
6f498847 107
108 //! Return floating signal catching value previously set by SetSignal().
109 Standard_EXPORT static Standard_Boolean ToCatchFloatingSignals();
110
42cf5bc1 111 //! Commands the process to sleep for a number of seconds.
112 Standard_EXPORT static void SecSleep (const Standard_Integer aDelay);
113
114 //! Commands the process to sleep for a number of milliseconds
115 Standard_EXPORT static void MilliSecSleep (const Standard_Integer aDelay);
116
42cf5bc1 117 //! Converts aReal into aCstring in exponential format with a period as
118 //! decimal point, no thousand separator and no grouping of digits.
119 //! The conversion is independant from the current locale
120 Standard_EXPORT static Standard_Boolean RealToCString (const Standard_Real aReal, Standard_PCharacter& aString);
42cf5bc1 121
122 //! Converts aCstring representing a real with a period as
123 //! decimal point, no thousand separator and no grouping of digits
124 //! into aReal .
125 //! The conversion is independant from the current locale.
126 Standard_EXPORT static Standard_Boolean CStringToReal (const Standard_CString aString, Standard_Real& aReal);
127
42cf5bc1 128 //! since Windows NT does not support 'SIGINT' signal like UNIX,
129 //! then this method checks whether Ctrl-Break keystroke was or
130 //! not. If yes then raises Exception_CTRL_BREAK.
131 Standard_EXPORT static void ControlBreak();
132
42cf5bc1 133};
134
42cf5bc1 135#endif // _OSD_HeaderFile