64
  C   ˆl–Ãa¾”êh¥2 ¸&®6â˜´o�þYe’,Ü¤’¸Æ ùÌ„!ŸË_‹I|¥�+ýÿ¹ä³ÀÊ 3<    #ifndef BOOST_WIN32_THREAD_PRIMITIVES_HPP
#define BOOST_WIN32_THREAD_PRIMITIVES_HPP

//  win32_thread_primitives.hpp
//
//  (C) Copyright 2005-7 Anthony Williams
//  (C) Copyright 2007 David Deakins
//
//  Distributed under the Boost Software License, Version 1.0. (See
//  accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

#include <boost/thread/detail/config.hpp>
#include <boost/predef/platform.h>
#include <boost/throw_exception.hpp>
#include <boost/assert.hpp>
#include <boost/thread/exceptions.hpp>
#include <boost/detail/interlocked.hpp>

#include <boost/winapi/config.hpp>
#include <boost/winapi/basic_types.hpp>
#include <boost/winapi/semaphore.hpp>
#include <boost/winapi/system.hpp>
#include <boost/winapi/event.hpp>
#include <boost/winapi/thread.hpp>
#include <boost/winapi/get_current_thread.hpp>
#include <boost/winapi/get_current_thread_id.hpp>
#include <boost/winapi/get_current_process.hpp>
#include <boost/winapi/get_current_process_id.hpp>
#include <boost/winapi/wait.hpp>
#include <boost/winapi/handles.hpp>
#include <boost/winapi/access_rights.hpp>

//#include <boost/winapi/synchronization.hpp>
#include <boost/thread/win32/interlocked_read.hpp>
#include <algorithm>

#if BOOST_PLAT_WINDOWS_RUNTIME
#include <thread>
#endif

namespace boost
{
    namespace detail
    {
        namespace win32
        {
            typedef ::boost::winapi::HANDLE_ handle;
            typedef ::boost::winapi::SYSTEM_INFO_ system_info;
            typedef ::boost::winapi::ULONGLONG_ ticks_type;
            unsigned const infinite=::boost::winapi::INFINITE_;
            unsigned const timeout=::boost::winapi::WAIT_TIMEOUT_;
            handle const invalid_handle_value=::boost::winapi::INVALID_HANDLE_VALUE_;
            unsigned const event_modify_state=::boost::winapi::EVENT_MODIFY_STATE_;
            unsigned const synchronize=::boost::winapi::SYNCHRONIZE_;
            unsigned const wait_abandoned=::boost::winapi::WAIT_ABANDONED_;
            unsigned const create_event_initial_set = 0x00000002;
            unsigned const create_event_manual_reset = 0x00000001;
            unsigned const event_all_access = ::boost::winapi::EVENT_ALL_ACCESS_;
            unsigned const semaphore_all_access = boost::winapi::SEMAPHORE_ALL_ACCESS_;
        }
    }
}

#include <boost/config/abi_prefix.hpp>

namespace boost
{
    namespace detail
    {
        namespace win32
        {
            namespace detail { typedef ticks_type (BOOST_WINAPI_WINAPI_CC *gettickcount64_t)(); }
            extern BOOST_THREAD_DECL boost::detail::win32::detail::gettickcount64_t gettickcount64;

            enum event_type
            {
                auto_reset_event=false,
                manual_reset_event=true
            };

            enum initial_event_state
            {
                event_initially_reset=false,
                event_initially_set=true
            };

            inline handle create_event(
#if !defined(BOOST_NO_ANSI_APIS)
                const char *mutex_name,
#else
                const wchar_t *mutex_name,
#endif
                event_type type,
                initial_event_state state)
            {
#if !defined(BOOST_NO_ANSI_APIS)
                handle const res = ::boost::winapi::CreateEventA(0, type, state, mutex_name);
#elif BOOST_USE_WINAPI_VERSION < BOOST_WINAPI_VERSION_VISTA
                handle const res = ::boost::winapi::CreateEventW(0, type, state, mutex_name);
#else
                handle const res = ::boost::winapi::CreateEventExW(
                    0,
                    mutex_name,
                    (type ? create_event_manual_reset : 0) | (state ? create_event_initial_set : 0),
                    event_all_access);
#endif
                return res;
            }

            inline handle create_anonymous_event(event_type type,initial_event_state state)
            {
                handle const res = create_event(0, type, state);
                if(!res)
                {
                 