summaryrefslogtreecommitdiffstats
path: root/net/tools/epoll_server
diff options
context:
space:
mode:
authortfarina <tfarina@chromium.org>2015-12-16 08:35:04 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-16 16:36:05 +0000
commitecbedb16be3bcccd4dd6d816f2951d1dbfed5221 (patch)
treec01efc810bd40785b52fe2b6caf8b4d66fae9a53 /net/tools/epoll_server
parentd192ed6d01bccd58a7d4f0ccc281725f6ba4e037 (diff)
downloadchromium_src-ecbedb16be3bcccd4dd6d816f2951d1dbfed5221.zip
chromium_src-ecbedb16be3bcccd4dd6d816f2951d1dbfed5221.tar.gz
chromium_src-ecbedb16be3bcccd4dd6d816f2951d1dbfed5221.tar.bz2
epoll_server: reuse base::AutoReset instead of TrueFalseGuad
This patch removes TrueFalseGuard class in favor of bases' AutoReset. BUG=None R=rch@chromium.org Review URL: https://codereview.chromium.org/1530713004 Cr-Commit-Position: refs/heads/master@{#365542}
Diffstat (limited to 'net/tools/epoll_server')
-rw-r--r--net/tools/epoll_server/epoll_server.cc20
1 files changed, 4 insertions, 16 deletions
diff --git a/net/tools/epoll_server/epoll_server.cc b/net/tools/epoll_server/epoll_server.cc
index 4c1d34b..78511c2 100644
--- a/net/tools/epoll_server/epoll_server.cc
+++ b/net/tools/epoll_server/epoll_server.cc
@@ -11,6 +11,7 @@
#include <utility>
#include <vector>
+#include "base/auto_reset.h"
#include "base/logging.h"
#include "base/time/time.h"
@@ -334,20 +335,6 @@ void EpollServer::HandleEvent(int fd, int event_mask) {
AddToReadyList(cb_and_mask);
}
-class TrueFalseGuard {
- public:
- explicit TrueFalseGuard(bool* guarded_bool) : guarded_bool_(guarded_bool) {
- DCHECK(guarded_bool_ != NULL);
- DCHECK(*guarded_bool_ == false);
- *guarded_bool_ = true;
- }
- ~TrueFalseGuard() {
- *guarded_bool_ = false;
- }
- private:
- bool* guarded_bool_;
-};
-
void EpollServer::WaitForEventsAndExecuteCallbacks() {
if (in_wait_for_events_and_execute_callbacks_) {
LOG(DFATAL) <<
@@ -358,7 +345,8 @@ void EpollServer::WaitForEventsAndExecuteCallbacks() {
// we never see it.
return; // COV_NF_LINE
}
- TrueFalseGuard recursion_guard(&in_wait_for_events_and_execute_callbacks_);
+ base::AutoReset<bool> recursion_guard(
+ &in_wait_for_events_and_execute_callbacks_, true);
if (alarm_map_.empty()) {
// no alarms, this is business as usual.
WaitForEventsAndCallHandleEvents(timeout_in_us_,
@@ -709,7 +697,7 @@ void EpollServer::CallReadyListCallbacks() {
// UnRegister call will now simply set the cb to NULL instead of
// invalidating the cb_and_mask object (by deleting the object in the
// map to which cb_and_mask refers)
- TrueFalseGuard in_use_guard(&(cb_and_mask->in_use));
+ base::AutoReset<bool> in_use_guard(&(cb_and_mask->in_use), true);
cb_and_mask->cb->OnEvent(cb_and_mask->fd, &event);
}