]> git.lyx.org Git - lyx.git/blob - boost/libs/regex/src/regex_synch.cpp
update
[lyx.git] / boost / libs / regex / src / regex_synch.cpp
1 /*
2  *
3  * Copyright (c) 1998-2002
4  * Dr John Maddock
5  *
6  * Permission to use, copy, modify, distribute and sell this software
7  * and its documentation for any purpose is hereby granted without fee,
8  * provided that the above copyright notice appear in all copies and
9  * that both that copyright notice and this permission notice appear
10  * in supporting documentation.  Dr John Maddock makes no representations
11  * about the suitability of this software for any purpose.
12  * It is provided "as is" without express or implied warranty.
13  *
14  */
15
16  /*
17   *   LOCATION:    see http://www.boost.org for most recent version.
18   *   FILE:        regex_synch.cpp
19   *   VERSION:     see <boost/version.hpp>
20   *   DESCRIPTION: Thread synch helper functions, for regular
21   *                expression library.
22   */
23
24
25 #define BOOST_REGEX_SOURCE
26
27 #include <boost/regex/detail/regex_synch.hpp>
28
29 namespace boost{
30    namespace re_detail{
31
32 void BOOST_REGEX_CALL re_init_threads()
33 {
34    BOOST_RE_GUARD_STACK
35 #ifdef BOOST_HAS_THREADS
36    if(p_re_lock == 0)
37       p_re_lock = new critical_section();
38    cs_guard g(*p_re_lock);
39    ++re_lock_count;
40 #endif
41 }
42
43 void BOOST_REGEX_CALL re_free_threads()
44 {
45    BOOST_RE_GUARD_STACK
46 #ifdef BOOST_HAS_THREADS
47    cs_guard g(*p_re_lock);
48    --re_lock_count;
49    if(re_lock_count == 0)
50    {
51       g.acquire(false);
52       delete p_re_lock;
53       p_re_lock = 0;
54    }
55 #endif
56 }
57
58 #ifdef BOOST_HAS_THREADS
59
60 BOOST_REGEX_DECL critical_section* p_re_lock = 0;
61
62 BOOST_REGEX_DECL unsigned int re_lock_count = 0;
63
64 #endif
65
66    } // namespace re_detail
67 } // namespace boost
68
69