Boost logo

Boost :

From: Synge Todo (wistaria_at_[hidden])
Date: 2003-04-11 03:53:52


Dear Boosters,

I'm sending small patches to Boost.Thread library, which is required
to compile with -DBOOST_NO_EXCEPTIONS. Could someone apply this patch?

Best regards,

Synge Todo
wistaria_at_[hidden]

diff -crN boost_1_30_0.orig/boost/thread/condition.hpp boost_1_30_0/boost/thread/condition.hpp
*** boost_1_30_0.orig/boost/thread/condition.hpp Wed Feb 5 08:08:25 2003
--- boost_1_30_0/boost/thread/condition.hpp Wed Apr 9 19:11:18 2003
***************
*** 91,97 ****
      void wait(L& lock)
      {
          if (!lock)
! throw lock_error();
  
          do_wait(lock.m_mutex);
      }
--- 91,97 ----
      void wait(L& lock)
      {
          if (!lock)
! throw_exception(lock_error());
  
          do_wait(lock.m_mutex);
      }
***************
*** 100,106 ****
      void wait(L& lock, Pr pred)
      {
          if (!lock)
! throw lock_error();
  
          while (!pred())
              do_wait(lock.m_mutex);
--- 100,106 ----
      void wait(L& lock, Pr pred)
      {
          if (!lock)
! throw_exception(lock_error());
  
          while (!pred())
              do_wait(lock.m_mutex);
***************
*** 110,116 ****
      bool timed_wait(L& lock, const xtime& xt)
      {
          if (!lock)
! throw lock_error();
  
          return do_timed_wait(lock.m_mutex, xt);
      }
--- 110,116 ----
      bool timed_wait(L& lock, const xtime& xt)
      {
          if (!lock)
! throw_exception(lock_error());
  
          return do_timed_wait(lock.m_mutex, xt);
      }
***************
*** 119,125 ****
      bool timed_wait(L& lock, const xtime& xt, Pr pred)
      {
          if (!lock)
! throw lock_error();
  
          while (!pred())
          {
--- 119,125 ----
      bool timed_wait(L& lock, const xtime& xt, Pr pred)
      {
          if (!lock)
! throw_exception(lock_error());
  
          while (!pred())
          {
diff -crN boost_1_30_0.orig/boost/thread/detail/lock.hpp boost_1_30_0/boost/thread/detail/lock.hpp
*** boost_1_30_0.orig/boost/thread/detail/lock.hpp Wed Feb 5 08:08:28 2003
--- boost_1_30_0/boost/thread/detail/lock.hpp Wed Apr 9 19:12:36 2003
***************
*** 75,87 ****
  
      void lock()
      {
! if (m_locked) throw lock_error();
          lock_ops<Mutex>::lock(m_mutex);
          m_locked = true;
      }
      void unlock()
      {
! if (!m_locked) throw lock_error();
          lock_ops<Mutex>::unlock(m_mutex);
          m_locked = false;
      }
--- 75,87 ----
  
      void lock()
      {
! if (m_locked) throw_exception(lock_error());
          lock_ops<Mutex>::lock(m_mutex);
          m_locked = true;
      }
      void unlock()
      {
! if (!m_locked) throw_exception(lock_error());
          lock_ops<Mutex>::unlock(m_mutex);
          m_locked = false;
      }
***************
*** 119,136 ****
  
      void lock()
      {
! if (m_locked) throw lock_error();
          lock_ops<TryMutex>::lock(m_mutex);
          m_locked = true;
      }
      bool try_lock()
      {
! if (m_locked) throw lock_error();
          return (m_locked = lock_ops<TryMutex>::trylock(m_mutex));
      }
      void unlock()
      {
! if (!m_locked) throw lock_error();
          lock_ops<TryMutex>::unlock(m_mutex);
          m_locked = false;
      }
--- 119,136 ----
  
      void lock()
      {
! if (m_locked) throw_exception(lock_error());
          lock_ops<TryMutex>::lock(m_mutex);
          m_locked = true;
      }
      bool try_lock()
      {
! if (m_locked) throw_exception(lock_error());
          return (m_locked = lock_ops<TryMutex>::trylock(m_mutex));
      }
      void unlock()
      {
! if (!m_locked) throw_exception(lock_error());
          lock_ops<TryMutex>::unlock(m_mutex);
          m_locked = false;
      }
***************
*** 168,185 ****
  
      void lock()
      {
! if (m_locked) throw lock_error();
          lock_ops<TimedMutex>::lock(m_mutex);
          m_locked = true;
      }
      bool timed_lock(const xtime& xt)
      {
! if (m_locked) throw lock_error();
          return (m_locked = lock_ops<TimedMutex>::timedlock(m_mutex, xt));
      }
      void unlock()
      {
! if (!m_locked) throw lock_error();
          lock_ops<TimedMutex>::unlock(m_mutex);
          m_locked = false;
      }
--- 168,185 ----
  
      void lock()
      {
! if (m_locked) throw_exception(lock_error());
          lock_ops<TimedMutex>::lock(m_mutex);
          m_locked = true;
      }
      bool timed_lock(const xtime& xt)
      {
! if (m_locked) throw_exception(lock_error());
          return (m_locked = lock_ops<TimedMutex>::timedlock(m_mutex, xt));
      }
      void unlock()
      {
! if (!m_locked) throw_exception(lock_error());
          lock_ops<TimedMutex>::unlock(m_mutex);
          m_locked = false;
      }
diff -crN boost_1_30_0.orig/boost/thread/exceptions.hpp boost_1_30_0/boost/thread/exceptions.hpp
*** boost_1_30_0.orig/boost/thread/exceptions.hpp Wed Feb 5 08:08:26 2003
--- boost_1_30_0/boost/thread/exceptions.hpp Wed Apr 9 19:21:22 2003
***************
*** 13,18 ****
--- 13,19 ----
  #define BOOST_THREAD_EXCEPTIONS_PDM070801_H
  
  #include <boost/config.hpp>
+ #include <boost/throw_exception.hpp>
  #include <boost/thread/detail/config.hpp>
  
  // pdm: Sorry, but this class is used all over the place & I end up
diff -crN boost_1_30_0.orig/libs/thread/src/condition.cpp boost_1_30_0/libs/thread/src/condition.cpp
*** boost_1_30_0.orig/libs/thread/src/condition.cpp Mon Feb 24 02:38:11 2003
--- boost_1_30_0/libs/thread/src/condition.cpp Wed Apr 9 19:06:22 2003
***************
*** 63,69 ****
                      assert(res);
                  }
  
! throw thread_resource_error();
          }
  }
  
--- 63,69 ----
                      assert(res);
                  }
  
! throw_exception(thread_resource_error());
          }
  }
  
***************
*** 340,346 ****
      int res = 0;
      res = pthread_cond_init(&m_condition, 0);
      if (res != 0)
! throw thread_resource_error();
  }
  
  condition_impl::~condition_impl()
--- 340,346 ----
      int res = 0;
      res = pthread_cond_init(&m_condition, 0);
      if (res != 0)
! throw_exception(thread_resource_error());
  }
  
  condition_impl::~condition_impl()
***************
*** 411,417 ****
                      assert(lStatus == noErr);
                  }
  
! throw thread_resource_error();
          }
  }
  
--- 411,417 ----
                      assert(lStatus == noErr);
                  }
  
! throw_exception(thread_resource_error());
          }
  }
  
diff -crN boost_1_30_0.orig/libs/thread/src/mutex.cpp boost_1_30_0/libs/thread/src/mutex.cpp
*** boost_1_30_0.orig/libs/thread/src/mutex.cpp Mon Feb 24 02:38:11 2003
--- boost_1_30_0/libs/thread/src/mutex.cpp Wed Apr 9 19:07:56 2003
***************
*** 42,48 ****
      {
      }
      if (!m_mutex)
! throw thread_resource_error();
      InitializeCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(m_mutex));
  }
  
--- 42,48 ----
      {
      }
      if (!m_mutex)
! throw_exception(thread_resource_error());
      InitializeCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(m_mutex));
  }
  
***************
*** 76,82 ****
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw thread_resource_error();
  }
  
  try_mutex::~try_mutex()
--- 76,82 ----
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw_exception(thread_resource_error());
  }
  
  try_mutex::~try_mutex()
***************
*** 122,128 ****
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw thread_resource_error();
  }
  
  timed_mutex::~timed_mutex()
--- 122,128 ----
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw_exception(thread_resource_error());
  }
  
  timed_mutex::~timed_mutex()
***************
*** 193,199 ****
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw thread_resource_error();
  }
  
  mutex::~mutex()
--- 193,199 ----
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw_exception(thread_resource_error());
  }
  
  mutex::~mutex()
***************
*** 207,213 ****
  {
      int res = 0;
      res = pthread_mutex_lock(&m_mutex);
! if (res == EDEADLK) throw lock_error();
      assert(res == 0);
  }
  
--- 207,213 ----
  {
      int res = 0;
      res = pthread_mutex_lock(&m_mutex);
! if (res == EDEADLK) throw_exception(lock_error());
      assert(res == 0);
  }
  
***************
*** 215,221 ****
  {
      int res = 0;
      res = pthread_mutex_unlock(&m_mutex);
! if (res == EPERM) throw lock_error();
      assert(res == 0);
  }
  
--- 215,221 ----
  {
      int res = 0;
      res = pthread_mutex_unlock(&m_mutex);
! if (res == EPERM) throw_exception(lock_error());
      assert(res == 0);
  }
  
***************
*** 233,239 ****
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw thread_resource_error();
  }
  
  try_mutex::~try_mutex()
--- 233,239 ----
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw_exception(thread_resource_error());
  }
  
  try_mutex::~try_mutex()
***************
*** 247,253 ****
  {
      int res = 0;
      res = pthread_mutex_lock(&m_mutex);
! if (res == EDEADLK) throw lock_error();
      assert(res == 0);
  }
  
--- 247,253 ----
  {
      int res = 0;
      res = pthread_mutex_lock(&m_mutex);
! if (res == EDEADLK) throw_exception(lock_error());
      assert(res == 0);
  }
  
***************
*** 255,261 ****
  {
      int res = 0;
      res = pthread_mutex_trylock(&m_mutex);
! if (res == EDEADLK) throw lock_error();
      assert(res == 0 || res == EBUSY);
      return res == 0;
  }
--- 255,261 ----
  {
      int res = 0;
      res = pthread_mutex_trylock(&m_mutex);
! if (res == EDEADLK) throw_exception(lock_error());
      assert(res == 0 || res == EBUSY);
      return res == 0;
  }
***************
*** 264,270 ****
  {
      int res = 0;
      res = pthread_mutex_unlock(&m_mutex);
! if (res == EPERM) throw lock_error();
      assert(res == 0);
  }
  
--- 264,270 ----
  {
      int res = 0;
      res = pthread_mutex_unlock(&m_mutex);
! if (res == EPERM) throw_exception(lock_error());
      assert(res == 0);
  }
  
***************
*** 283,295 ****
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw thread_resource_error();
  
      res = pthread_cond_init(&m_condition, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw thread_resource_error();
      }
  }
  
--- 283,295 ----
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw_exception(thread_resource_error());
  
      res = pthread_cond_init(&m_condition, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw_exception(thread_resource_error());
      }
  }
  
diff -crN boost_1_30_0.orig/libs/thread/src/recursive_mutex.cpp boost_1_30_0/libs/thread/src/recursive_mutex.cpp
*** boost_1_30_0.orig/libs/thread/src/recursive_mutex.cpp Mon Feb 24 02:38:11 2003
--- boost_1_30_0/libs/thread/src/recursive_mutex.cpp Wed Apr 9 19:09:24 2003
***************
*** 41,47 ****
          {
          }
      if (!m_mutex)
! throw thread_resource_error();
      InitializeCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(m_mutex));
  }
  
--- 41,47 ----
          {
          }
      if (!m_mutex)
! throw_exception(thread_resource_error());
      InitializeCriticalSection(reinterpret_cast<LPCRITICAL_SECTION>(m_mutex));
  }
  
***************
*** 83,89 ****
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw thread_resource_error();
  }
  
  recursive_try_mutex::~recursive_try_mutex()
--- 83,89 ----
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw_exception(thread_resource_error());
  }
  
  recursive_try_mutex::~recursive_try_mutex()
***************
*** 158,164 ****
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw thread_resource_error();
  }
  
  recursive_timed_mutex::~recursive_timed_mutex()
--- 158,164 ----
  {
      m_mutex = reinterpret_cast<void*>(CreateMutex(0, 0, 0));
      if (!m_mutex)
! throw_exception(thread_resource_error());
  }
  
  recursive_timed_mutex::~recursive_timed_mutex()
***************
*** 280,293 ****
  
      res = pthread_mutex_init(&m_mutex, &attr);
      if (res != 0)
! throw thread_resource_error();
  
  # if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
      res = pthread_cond_init(&m_unlocked, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw thread_resource_error();
      }
  # endif
  }
--- 280,293 ----
  
      res = pthread_mutex_init(&m_mutex, &attr);
      if (res != 0)
! throw_exception(thread_resource_error());
  
  # if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
      res = pthread_cond_init(&m_unlocked, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw_exception(thread_resource_error());
      }
  # endif
  }
***************
*** 357,363 ****
      {
          res = pthread_mutex_unlock(&m_mutex);
          assert(res == 0);
! throw lock_error();
      }
  
      if (--m_count == 0)
--- 357,363 ----
      {
          res = pthread_mutex_unlock(&m_mutex);
          assert(res == 0);
! throw_exception(lock_error());
      }
  
      if (--m_count == 0)
***************
*** 432,445 ****
  
      res = pthread_mutex_init(&m_mutex, &attr);
      if (res != 0)
! throw thread_resource_error();
  
  # if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
      res = pthread_cond_init(&m_unlocked, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw thread_resource_error();
      }
  # endif
  }
--- 432,445 ----
  
      res = pthread_mutex_init(&m_mutex, &attr);
      if (res != 0)
! throw_exception(thread_resource_error());
  
  # if !defined(BOOST_HAS_PTHREAD_MUTEXATTR_SETTYPE)
      res = pthread_cond_init(&m_unlocked, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw_exception(thread_resource_error());
      }
  # endif
  }
***************
*** 553,559 ****
      {
          res = pthread_mutex_unlock(&m_mutex);
          assert(res == 0);
! throw lock_error();
      }
  
      if (--m_count == 0)
--- 553,559 ----
      {
          res = pthread_mutex_unlock(&m_mutex);
          assert(res == 0);
! throw_exception(lock_error());
      }
  
      if (--m_count == 0)
***************
*** 616,628 ****
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw thread_resource_error();
  
      res = pthread_cond_init(&m_unlocked, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw thread_resource_error();
      }
  }
  
--- 616,628 ----
      int res = 0;
      res = pthread_mutex_init(&m_mutex, 0);
      if (res != 0)
! throw_exception(thread_resource_error());
  
      res = pthread_cond_init(&m_unlocked, 0);
      if (res != 0)
      {
          pthread_mutex_destroy(&m_mutex);
! throw_exception(thread_resource_error());
      }
  }
  
***************
*** 739,745 ****
      {
          res = pthread_mutex_unlock(&m_mutex);
          assert(res == 0);
! throw lock_error();
      }
  
      if (--m_count == 0)
--- 739,745 ----
      {
          res = pthread_mutex_unlock(&m_mutex);
          assert(res == 0);
! throw_exception(lock_error());
      }
  
      if (--m_count == 0)
diff -crN boost_1_30_0.orig/libs/thread/src/thread.cpp boost_1_30_0/libs/thread/src/thread.cpp
*** boost_1_30_0.orig/libs/thread/src/thread.cpp Wed Feb 5 08:22:58 2003
--- boost_1_30_0/libs/thread/src/thread.cpp Wed Apr 9 19:10:01 2003
***************
*** 110,121 ****
      m_thread = reinterpret_cast<void*>(_beginthreadex(0, 0, &thread_proxy,
                                             &param, 0, &m_id));
      if (!m_thread)
! throw thread_resource_error();
  #elif defined(BOOST_HAS_PTHREADS)
      int res = 0;
      res = pthread_create(&m_thread, 0, &thread_proxy, &param);
      if (res != 0)
! throw thread_resource_error();
  #elif defined(BOOST_HAS_MPTASKS)
      threads::mac::detail::thread_init();
      threads::mac::detail::create_singletons();
--- 110,121 ----
      m_thread = reinterpret_cast<void*>(_beginthreadex(0, 0, &thread_proxy,
                                             &param, 0, &m_id));
      if (!m_thread)
! throw_exception(thread_resource_error());
  #elif defined(BOOST_HAS_PTHREADS)
      int res = 0;
      res = pthread_create(&m_thread, 0, &thread_proxy, &param);
      if (res != 0)
! throw_exception(thread_resource_error());
  #elif defined(BOOST_HAS_MPTASKS)
      threads::mac::detail::thread_init();
      threads::mac::detail::create_singletons();
***************
*** 125,131 ****
      m_pTaskID = kInvalidID;
  
      lStatus = MPCreateQueue(&m_pJoinQueueID);
! if (lStatus != noErr) throw thread_resource_error();
  
      lStatus = MPCreateTask(&thread_proxy, &param, 0UL, m_pJoinQueueID, NULL,
          NULL, 0UL, &m_pTaskID);
--- 125,131 ----
      m_pTaskID = kInvalidID;
  
      lStatus = MPCreateQueue(&m_pJoinQueueID);
! if (lStatus != noErr) throw_exception(thread_resource_error());
  
      lStatus = MPCreateTask(&thread_proxy, &param, 0UL, m_pJoinQueueID, NULL,
          NULL, 0UL, &m_pTaskID);
***************
*** 133,139 ****
      {
          lStatus = MPDeleteQueue(m_pJoinQueueID);
          assert(lStatus == noErr);
! throw thread_resource_error();
      }
  #endif
      param.wait();
--- 133,139 ----
      {
          lStatus = MPDeleteQueue(m_pJoinQueueID);
          assert(lStatus == noErr);
! throw_exception(thread_resource_error());
      }
  #endif
      param.wait();
diff -crN boost_1_30_0.orig/libs/thread/src/tss.cpp boost_1_30_0/libs/thread/src/tss.cpp
*** boost_1_30_0.orig/libs/thread/src/tss.cpp Wed Feb 5 08:22:59 2003
--- boost_1_30_0/libs/thread/src/tss.cpp Wed Apr 9 19:17:37 2003
***************
*** 155,161 ****
  {
      m_key = TlsAlloc();
      if (m_key == 0xFFFFFFFF)
! throw thread_resource_error();
  
      m_cleanup = cleanup;
  }
--- 155,161 ----
  {
      m_key = TlsAlloc();
      if (m_key == 0xFFFFFFFF)
! throw_exception(thread_resource_error());
  
      m_cleanup = cleanup;
  }
***************
*** 191,197 ****
      int res = 0;
      res = pthread_key_create(&m_key, cleanup);
      if (res != 0)
! throw thread_resource_error();
  }
  
  tss::~tss()
--- 191,197 ----
      int res = 0;
      res = pthread_key_create(&m_key, cleanup);
      if (res != 0)
! throw_exception(thread_resource_error());
  }
  
  tss::~tss()
***************
*** 215,221 ****
  {
      OSStatus lStatus = MPAllocateTaskStorageIndex(&m_key);
      if(lStatus != noErr)
! throw thread_resource_error();
  
      m_cleanup = cleanup;
  }
--- 215,221 ----
  {
      OSStatus lStatus = MPAllocateTaskStorageIndex(&m_key);
      if(lStatus != noErr)
! throw_exception(thread_resource_error());
  
      m_cleanup = cleanup;
  }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk