[boost] Re: [Boost.Thread] mutex Win32 implementation changes
by Alexander Terekhov other posts by this author
Jul 20 2004 7:06PM messages near this date
[boost] Re: [Boost.Thread] mutex Win32 implementation changes
|
Re: [boost] Re: [Boost.Thread] mutex Win32 implementation changes
Peter Dimov wrote:
[...]
> > I have PS/2 Model 80 (with 64 Megs) "tank" at home (in addition to
> > A31p ThinkPad ;-) ).
>
> He he. OK, if you had CAS (PS/2 Model 70 486) how would you do it?
Ok, you owe me a "Blue Lightening" processor upgrade. ;-) How about
void lock() throw() {
while (int lock_status = m_lock_status.cas(0, 1, msync::ddacq))
if (lock_status < 0 || m_lock_status.cas(1,-1, msync::ddacq))
m_retry_event.wait();
}
bool trylock() throw() {
return !m_lock_status.cas(0, 1, msync::acq);
}
bool timedlock(absolute_timeout const & timeout) throw() {
while (int lock_status = m_lock_status.cas(0, 1, msync::ddacq))
if (lock_status < 0 || m_lock_status.cas(1,-1, msync::ddacq))
if (!m_retry_event.timedwait(timeout)) m_retry_event.set(),
return !m_lock_status.swap(1, msync::acq);
return true;
}
void unlock() throw() {
if (m_lock_status.swap(0, msync::rel) < 0)
m_retry_event.set();
}
<?>
regards,
alexander.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Thread:
Michael Glassford
Alexander Terekhov
Alexander Terekhov
Alexander Terekhov
Peter Dimov
Alexander Terekhov
Alexander Terekhov
Alexander Terekhov
val salamakha
val salamakha
val salamakha
val salamakha
Peter Dimov
Alexander Terekhov
Peter Dimov
Alexander Terekhov
Peter Dimov
Peter Dimov
Alexander Terekhov
Peter Dimov
Alexander Terekhov
Alexander Terekhov
Alexander Terekhov
Alexander Terekhov
Alexander Terekhov
Michael Glassford
Alexander Terekhov
Michael Glassford
|