|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r86479 - trunk/boost/sync/detail/condition_variables
From: andrey.semashev_at_[hidden]
Date: 2013-10-27 09:20:44
Author: andysem
Date: 2013-10-27 09:20:44 EDT (Sun, 27 Oct 2013)
New Revision: 86479
URL: http://svn.boost.org/trac/boost/changeset/86479
Log:
Total waiter count updates made more efficient.
Text files modified:
trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp | 29 ++++++++---------------------
1 files changed, 8 insertions(+), 21 deletions(-)
Modified: trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp
==============================================================================
--- trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp Sun Oct 27 09:14:12 2013 (r86478)
+++ trunk/boost/sync/detail/condition_variables/basic_condition_variable_windows.hpp 2013-10-27 09:20:44 EDT (Sun, 27 Oct 2013) (r86479)
@@ -329,7 +329,8 @@
--state->m_waiter_count;
if (state->m_notify_count > 0)
--state->m_notify_count;
- update_total_waiter_count();
+ else
+ interlocked_write_release(&m_total_waiter_count, m_total_waiter_count - 1);
}
BOOST_SYNC_DETAIL_THROW(wait_error, (err)("condition_variable wait failed in WaitForSingleObject"));
}
@@ -380,7 +381,8 @@
--state->m_waiter_count;
if (state->m_notify_count > 0)
--state->m_notify_count;
- update_total_waiter_count();
+ else
+ interlocked_write_release(&m_total_waiter_count, m_total_waiter_count - 1);
}
BOOST_SYNC_DETAIL_THROW(wait_error, (err)("condition_variable timed_wait failed in WaitForSingleObject"));
}
@@ -395,7 +397,7 @@
--state->m_notify_count;
return sync::cv_status::no_timeout;
}
- update_total_waiter_count();
+ interlocked_write_release(&m_total_waiter_count, m_total_waiter_count - 1);
return sync::cv_status::timeout;
}
@@ -416,7 +418,8 @@
--state->m_waiter_count;
if (state->m_notify_count > 0)
--state->m_notify_count;
- update_total_waiter_count();
+ else
+ interlocked_write_release(&m_total_waiter_count, m_total_waiter_count - 1);
}
BOOST_SYNC_DETAIL_THROW(wait_error, (err)("condition_variable timed_wait failed in WaitForMultipleObjects"));
}
@@ -446,7 +449,7 @@
--state->m_notify_count;
return sync::cv_status::no_timeout;
}
- update_total_waiter_count();
+ interlocked_write_release(&m_total_waiter_count, m_total_waiter_count - 1);
return sync::cv_status::timeout;
}
break;
@@ -456,22 +459,6 @@
}
}
}
-
- void update_total_waiter_count() BOOST_NOEXCEPT
- {
- long total_waiter_count = 0;
- if (waiter_state* p = m_notify_state)
- {
- waiter_state* const end = p;
- do
- {
- total_waiter_count += p->m_waiter_count;
- p = p->m_next;
- }
- while (p != end);
- }
- interlocked_write_release(&m_total_waiter_count, total_waiter_count);
- }
};
} // namespace windows
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