$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2004-06-12 10:24:55
Chuck Allison wrote:
[...]
>   viewing at http://www.artima.com/cppsource. The idea is to have
Quoting from http://www.artima.com/intv/elegance.html. Few comments
follow.
<quote author=Bjarne Stroustrup>
I don't put in specific features for concurrency, because you can put 
them in a library. 
</quote>
You can't do that without threaded memory model, to begin with.
<quote>
C was designed with the principle that you should be able to write 
its standard library in the language itself. That same principle 
guided the design of C++. 
</quote>
Show me the the standard C++ impl of atomic<> for a rather simple
thing like
class swap_based_mutex_for_windows { // noncopyable
  atomic<int>      m_lock_status; // 0: free, 1/-1: locked/contention
  auto_reset_event m_retry_event; // "slow" bin sema/gate
public:
  // ctor/dtor [w/o lazy event init] 
  void lock() throw() {
    if (m_lock_status.swap(1, msync::acq)) 
      while (m_lock_status.swap(-1, msync::acq))
        m_retry_event.wait();
  } 
  bool trylock() throw() {
    return !m_lock_status.swap(1, msync::acq) ? 
      true : !m_lock_status.swap(-1, msync::acq);
  }
  bool timedlock(absolute_timeout const & timeout) throw() {
    if (m_lock_status.swap(1, msync::acq)) {
      while (m_lock_status.swap(-1, msync::acq))
        if (!m_retry_event.timedwait(timeout)) 
          return false;
    } 
    return true;
  }
  void unlock() throw() {
    if (m_lock_status.swap(0, msync::rel) < 0) 
      m_retry_event.set();
  } 
};
regards,
alexander.