MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / timed_lock

Method timed_lock

extern/boost/boost/thread/pthread/mutex.hpp:136–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

134#if defined BOOST_THREAD_USES_DATETIME
135 template<typename TimeDuration>
136 bool timed_lock(TimeDuration const & relative_time)
137 {
138 if (relative_time.is_pos_infinity())
139 {
140 lock();
141 return true;
142 }
143 if (relative_time.is_special())
144 {
145 return true;
146 }
147 detail::platform_duration d(relative_time);
148#if defined(BOOST_THREAD_HAS_MONO_CLOCK) && !defined(BOOST_THREAD_INTERNAL_CLOCK_IS_MONO)
149 const detail::mono_platform_timepoint ts(detail::mono_platform_clock::now() + d);
150 d = (std::min)(d, detail::platform_milliseconds(BOOST_THREAD_POLL_INTERVAL_MILLISECONDS));
151 while ( ! do_try_lock_until(detail::internal_platform_clock::now() + d) )
152 {
153 d = ts - detail::mono_platform_clock::now();
154 if ( d <= detail::platform_duration::zero() ) return false; // timeout occurred
155 d = (std::min)(d, detail::platform_milliseconds(BOOST_THREAD_POLL_INTERVAL_MILLISECONDS));
156 }
157 return true;
158#else
159 return do_try_lock_until(detail::internal_platform_clock::now() + d);
160#endif
161 }
162 bool timed_lock(boost::xtime const & absolute_time)
163 {
164 return timed_lock(system_time(absolute_time));

Callers

nothing calls this directly

Calls 6

platform_millisecondsFunction · 0.85
zeroFunction · 0.85
timed_lockFunction · 0.85
lockFunction · 0.50
is_pos_infinityMethod · 0.45
is_specialMethod · 0.45

Tested by

no test coverage detected