File indexing completed on 2025-07-11 08:13:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_INTERPROCESS_DETAIL_WINAPI_WRAPPER_COMMON_HPP
0012 #define BOOST_INTERPROCESS_DETAIL_WINAPI_WRAPPER_COMMON_HPP
0013
0014 #ifndef BOOST_CONFIG_HPP
0015 # include <boost/config.hpp>
0016 #endif
0017 #
0018 #if defined(BOOST_HAS_PRAGMA_ONCE)
0019 # pragma once
0020 #endif
0021
0022 #include <boost/interprocess/detail/config_begin.hpp>
0023 #include <boost/interprocess/detail/workaround.hpp>
0024 #include <boost/interprocess/detail/win32_api.hpp>
0025 #include <boost/interprocess/errors.hpp>
0026 #include <boost/interprocess/exceptions.hpp>
0027 #include <boost/interprocess/timed_utils.hpp>
0028 #include <limits>
0029
0030 namespace boost {
0031 namespace interprocess {
0032 namespace ipcdetail {
0033
0034 inline bool do_winapi_wait(void *handle, unsigned long dwMilliseconds)
0035 {
0036 unsigned long ret = winapi::wait_for_single_object(handle, dwMilliseconds);
0037 if(ret == winapi::wait_object_0){
0038 return true;
0039 }
0040 else if(ret == winapi::wait_timeout){
0041 return false;
0042 }
0043 else if(ret == winapi::wait_abandoned){
0044 winapi::release_mutex(handle);
0045 throw interprocess_exception(owner_dead_error);
0046 }
0047 else{
0048 error_info err = system_error_code();
0049 throw interprocess_exception(err);
0050 }
0051 }
0052
0053 template<class TimePoint>
0054 inline bool winapi_wrapper_timed_wait_for_single_object(void *handle, const TimePoint &abs_time)
0055 {
0056
0057
0058 unsigned long time_ms = 0u;
0059 if (ipcdetail::is_pos_infinity(abs_time)){
0060 time_ms = winapi::infinite_time;
0061 }
0062 else {
0063 typedef typename microsec_clock<TimePoint>::time_point time_point;
0064 const time_point cur_time = microsec_clock<TimePoint>::universal_time();
0065 if(abs_time > cur_time){
0066 time_ms = static_cast<unsigned long>(duration_to_milliseconds(abs_time - cur_time));
0067 }
0068 }
0069 return do_winapi_wait(handle, time_ms);
0070 }
0071
0072 inline void winapi_wrapper_wait_for_single_object(void *handle)
0073 {
0074 (void)do_winapi_wait(handle, winapi::infinite_time);
0075 }
0076
0077 inline bool winapi_wrapper_try_wait_for_single_object(void *handle)
0078 {
0079 return do_winapi_wait(handle, 0u);
0080 }
0081
0082 }
0083 }
0084 }
0085
0086 #include <boost/interprocess/detail/config_end.hpp>
0087
0088 #endif