inline bool winapi_wrapper_timed_wait_for_single_object(void *handle, const geofeatures_boost::posix_time::ptime &abs_time) { //Windows does not support infinity abs_time so check it if(abs_time == geofeatures_boost::posix_time::pos_infin){ winapi_wrapper_wait_for_single_object(handle); return true; } const geofeatures_boost::posix_time::ptime cur_time = microsec_clock::universal_time(); //Windows uses relative wait times so check for negative waits //and implement as 0 wait to allow try-semantics as POSIX mandates. unsigned long ret = winapi::wait_for_single_object ( handle , (abs_time <= cur_time) ? 0u : (abs_time - cur_time).total_milliseconds() ); if(ret == winapi::wait_object_0){ return true; } else if(ret == winapi::wait_timeout){ return false; } else{ error_info err = system_error_code(); throw interprocess_exception(err); } }
void wait() { return winapi_wrapper_wait_for_single_object(m_sem_hnd); }
void lock() { return winapi_wrapper_wait_for_single_object(m_mtx_hnd); }