Files
boost_regex/src/regex_synch.cpp
T

75 lines
1.4 KiB
C++
Raw Normal View History

2000-09-26 11:48:28 +00:00
/*
*
* Copyright (c) 1998-2002
2000-09-26 11:48:28 +00:00
* Dr John Maddock
*
2003-10-04 11:29:20 +00:00
* Use, modification and distribution are subject to the
2003-09-30 13:02:51 +00:00
* Boost Software License, Version 1.0. (See accompanying file
* LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
2000-09-26 11:48:28 +00:00
*
*/
/*
* LOCATION: see http://www.boost.org for most recent version.
* FILE: regex_synch.cpp
* VERSION: see <boost/version.hpp>
2000-09-26 11:48:28 +00:00
* DESCRIPTION: Thread synch helper functions, for regular
* expression library.
*/
#define BOOST_REGEX_SOURCE
2003-05-17 11:45:48 +00:00
#include <boost/regex/config.hpp>
#ifdef BOOST_REGEX_V3
#include <boost/regex/v3/regex_synch.hpp>
2003-05-17 11:45:48 +00:00
#else
#include <boost/regex/v4/regex_synch.hpp>
#endif
2000-09-26 11:48:28 +00:00
namespace boost{
namespace re_detail{
void BOOST_REGEX_CALL re_init_threads()
2000-09-26 11:48:28 +00:00
{
BOOST_RE_GUARD_STACK
#ifdef BOOST_HAS_THREADS
2000-09-26 11:48:28 +00:00
if(p_re_lock == 0)
p_re_lock = new critical_section();
cs_guard g(*p_re_lock);
++re_lock_count;
#endif
}
void BOOST_REGEX_CALL re_free_threads()
2000-09-26 11:48:28 +00:00
{
BOOST_RE_GUARD_STACK
#ifdef BOOST_HAS_THREADS
2000-09-26 11:48:28 +00:00
cs_guard g(*p_re_lock);
--re_lock_count;
if(re_lock_count == 0)
{
g.acquire(false);
delete p_re_lock;
p_re_lock = 0;
}
#endif
}
#ifdef BOOST_HAS_THREADS
2000-09-26 11:48:28 +00:00
BOOST_REGEX_DECL critical_section* p_re_lock = 0;
2000-09-26 11:48:28 +00:00
BOOST_REGEX_DECL unsigned int re_lock_count = 0;
2000-09-26 11:48:28 +00:00
#endif
} // namespace re_detail
} // namespace boost
2003-05-17 11:45:48 +00:00
2003-09-30 13:02:51 +00:00