Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85788 - in trunk/boost/sync/detail: event semaphore
From: tim_at_[hidden]
Date: 2013-09-19 05:00:49


Author: timblechmann
Date: 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013)
New Revision: 85788
URL: http://svn.boost.org/trac/boost/changeset/85788

Log:
sync: event/semaphore - annotate functions with noexcept

Text files modified:
   trunk/boost/sync/detail/event/event_emulation.hpp | 2 +-
   trunk/boost/sync/detail/event/event_mach.hpp | 22 +++++++++++-----------
   trunk/boost/sync/detail/event/event_windows.hpp | 2 +-
   trunk/boost/sync/detail/semaphore/semaphore_dispatch.hpp | 18 +++++++++---------
   trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp | 5 ++---
   trunk/boost/sync/detail/semaphore/semaphore_posix.hpp | 18 +++++++++---------
   trunk/boost/sync/detail/semaphore/semaphore_windows.hpp | 5 +++--
   7 files changed, 36 insertions(+), 36 deletions(-)

Modified: trunk/boost/sync/detail/event/event_emulation.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_emulation.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/event/event_emulation.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -30,7 +30,7 @@
     BOOST_DELETED_FUNCTION(event& operator=(event const&));
 
 public:
- explicit event(bool auto_reset = false) :
+ explicit event(bool auto_reset = false) BOOST_NOEXCEPT :
         m_auto_reset(auto_reset), m_is_set(false)
     {}
 

Modified: trunk/boost/sync/detail/event/event_mach.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_mach.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/event/event_mach.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -38,20 +38,20 @@
     BOOST_DELETED_FUNCTION(event& operator=(event const&));
 
 public:
- explicit event(bool auto_reset = false):
+ explicit event(bool auto_reset = false) BOOST_NOEXCEPT:
         m_auto_reset(auto_reset), m_state(0)
     {
         kern_return_t result = semaphore_create(mach_task_self(), &m_sem, SYNC_POLICY_FIFO, 0);
         BOOST_VERIFY(result == KERN_SUCCESS);
     }
 
- ~event()
+ ~event() BOOST_NOEXCEPT
     {
         kern_return_t result = semaphore_destroy(mach_task_self(), m_sem);
         BOOST_VERIFY(result == KERN_SUCCESS);
     }
 
- void post()
+ void post() BOOST_NOEXCEPT
     {
         if (m_auto_reset) {
             bool was_signalled;
@@ -73,12 +73,12 @@
         }
     }
 
- void reset()
+ void reset() BOOST_NOEXCEPT
     {
         m_state = 0; // CHECK: do we need to increment the ABA tag?
     }
 
- void wait()
+ void wait() BOOST_NOEXCEPT
     {
         if (m_auto_reset) {
             kern_return_t result = semaphore_wait( m_sem );
@@ -97,24 +97,24 @@
         }
     }
 
- bool try_wait()
+ bool try_wait() BOOST_NOEXCEPT
     {
         const mach_timespec_t immediate = {0, 0};
         return do_try_wait_until(immediate);
     }
 
     template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & duration)
+ bool try_wait_for(const chrono::duration<Rep, Period> & duration) BOOST_NOEXCEPT
     {
- BOOST_AUTO ( seconds, chrono::duration_cast<chrono::seconds>(duration) );
- BOOST_AUTO ( nanoseconds, chrono::duration_cast<chrono::nanoseconds>(duration) - seconds );
+ chrono::seconds seconds = chrono::duration_cast<chrono::seconds>(duration);
+ chrono::nanoseconds nanoseconds = chrono::duration_cast<chrono::nanoseconds>(duration) - seconds;
 
- const mach_timespec_t mach_duration = { seconds.count(), nanoseconds.count() };
+ const mach_timespec_t mach_duration = { static_cast<unsigned int>(seconds.count()), static_cast<clock_res_t>(nanoseconds.count()) };
         return do_try_wait_until( mach_duration );
     }
 
     template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout )
+ bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
     {
         return try_wait_for( timeout - Clock::now() );
     }

Modified: trunk/boost/sync/detail/event/event_windows.hpp
==============================================================================
--- trunk/boost/sync/detail/event/event_windows.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/event/event_windows.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -53,7 +53,7 @@
         }
     }
 
- ~event()
+ ~event() BOOST_NOEXCEPT
     {
         BOOST_VERIFY( boost::detail::win32::CloseHandle(handle_) );
     }

Modified: trunk/boost/sync/detail/semaphore/semaphore_dispatch.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_dispatch.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/semaphore/semaphore_dispatch.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -47,22 +47,22 @@
             BOOST_THROW_EXCEPTION(resource_error(sync::detail::system_namespace::errc::not_enough_memory, "boost::sync::semaphore constructor failed in dispatch_semaphore_create"));
     }
 
- ~semaphore()
+ ~semaphore() BOOST_NOEXCEPT
     {
         dispatch_release(m_sem);
     }
 
- void post()
+ void post() BOOST_NOEXCEPT
     {
         dispatch_semaphore_signal(m_sem);
     }
 
- void wait()
+ void wait() BOOST_NOEXCEPT
     {
         dispatch_semaphore_wait(m_sem, DISPATCH_TIME_FOREVER);
     }
 
- bool try_wait(void)
+ bool try_wait(void) BOOST_NOEXCEPT
     {
         const long status = dispatch_semaphore_wait(m_sem, DISPATCH_TIME_NOW);
         return status == 0;
@@ -70,13 +70,13 @@
 
 #ifdef BOOST_SYNC_USES_CHRONO
     template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & rel_time)
+ bool try_wait_for(const chrono::duration<Rep, Period> & rel_time) BOOST_NOEXCEPT
     {
         return try_wait_until(chrono::steady_clock::now() + rel_time);
     }
 
     template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout )
+ bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
     {
         using namespace chrono;
         system_clock::time_point s_now = system_clock::now();
@@ -85,14 +85,14 @@
     }
 
     template <class Duration>
- bool try_wait_until(const chrono::time_point<chrono::system_clock, Duration>& t)
+ bool try_wait_until(const chrono::time_point<chrono::system_clock, Duration>& t) BOOST_NOEXCEPT
     {
         using namespace chrono;
         typedef time_point<system_clock, nanoseconds> nano_sys_tmpt;
         return try_wait_until(nano_sys_tmpt(ceil<nanoseconds>(t.time_since_epoch())));
     }
 
- bool try_wait_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp)
+ bool try_wait_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp) BOOST_NOEXCEPT
     {
         chrono::nanoseconds d = tp.time_since_epoch();
         timespec ts = boost::detail::to_timespec(d);
@@ -100,7 +100,7 @@
     }
 
 private:
- bool do_wait_lock_until(const dispatch_time_t timeout)
+ bool do_wait_lock_until(const dispatch_time_t timeout) BOOST_NOEXCEPT
     {
         const long status = dispatch_semaphore_wait(m_sem, timeout);
         return status == 0;

Modified: trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/semaphore/semaphore_emulation.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -42,10 +42,9 @@
     BOOST_DELETED_FUNCTION(semaphore& operator=(semaphore const&))
 
 public:
- explicit semaphore(unsigned int i = 0) :
+ explicit semaphore(unsigned int i = 0) BOOST_NOEXCEPT :
         m_count(i)
- {
- }
+ {}
 
     void post(void)
     {

Modified: trunk/boost/sync/detail/semaphore/semaphore_posix.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_posix.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/semaphore/semaphore_posix.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -51,7 +51,7 @@
         }
     }
 
- ~semaphore()
+ ~semaphore() BOOST_NOEXCEPT
     {
         BOOST_VERIFY(sem_destroy(&m_sem) == 0);
     }
@@ -77,7 +77,7 @@
         }
     }
 
- void wait(void)
+ void wait(void) BOOST_NOEXCEPT
     {
         for (;;)
         {
@@ -99,7 +99,7 @@
         }
     }
 
- bool try_wait(void)
+ bool try_wait(void) BOOST_NOEXCEPT
     {
         const int status = sem_trywait(&m_sem);
         if (status == 0)
@@ -120,13 +120,13 @@
 
 #ifdef BOOST_SYNC_USES_CHRONO
     template <class Rep, class Period>
- bool try_wait_for(const chrono::duration<Rep, Period> & rel_time)
+ bool try_wait_for(const chrono::duration<Rep, Period> & duration) BOOST_NOEXCEPT
     {
- return try_wait_until(chrono::steady_clock::now() + rel_time);
+ return try_wait_until(chrono::steady_clock::now() + duration);
     }
 
     template <class Clock, class Duration>
- bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout )
+ bool try_wait_until(const chrono::time_point<Clock, Duration> & timeout ) BOOST_NOEXCEPT
     {
         using namespace chrono;
         system_clock::time_point s_now = system_clock::now();
@@ -135,14 +135,14 @@
     }
 
     template <class Duration>
- bool try_wait_until(const chrono::time_point<chrono::system_clock, Duration>& t)
+ bool try_wait_until(const chrono::time_point<chrono::system_clock, Duration>& t) BOOST_NOEXCEPT
     {
         using namespace chrono;
         typedef time_point<system_clock, nanoseconds> nano_sys_tmpt;
         return try_wait_until(nano_sys_tmpt(ceil<nanoseconds>(t.time_since_epoch())));
     }
 
- bool try_wait_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp)
+ bool try_wait_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>& tp) BOOST_NOEXCEPT
     {
         chrono::nanoseconds d = tp.time_since_epoch();
         timespec ts = boost::detail::to_timespec(d);
@@ -150,7 +150,7 @@
     }
 
 private:
- bool do_wait_lock_until(struct timespec const & timeout)
+ bool do_wait_lock_until(struct timespec const & timeout) BOOST_NOEXCEPT
     {
         for (;;)
         {

Modified: trunk/boost/sync/detail/semaphore/semaphore_windows.hpp
==============================================================================
--- trunk/boost/sync/detail/semaphore/semaphore_windows.hpp Thu Sep 19 05:00:23 2013 (r85787)
+++ trunk/boost/sync/detail/semaphore/semaphore_windows.hpp 2013-09-19 05:00:49 EDT (Thu, 19 Sep 2013) (r85788)
@@ -50,9 +50,10 @@
         }
     }
 
- ~semaphore()
+ ~semaphore() BOOST_NOEXCEPT
     {
- boost::detail::win32::CloseHandle(m_sem);
+ int status = boost::detail::win32::CloseHandle(m_sem);
+ BOOST_VERIFY (status != 0);
     }
 
     void post()


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk