Index: net/tools/epoll_server/epoll_server.h |
diff --git a/net/tools/epoll_server/epoll_server.h b/net/tools/epoll_server/epoll_server.h |
index 8822450860073b0cad866c5d66858601d26ecdfc..3d329b417a41811589facea465ca1fc93af61b98 100644 |
--- a/net/tools/epoll_server/epoll_server.h |
+++ b/net/tools/epoll_server/epoll_server.h |
@@ -46,15 +46,13 @@ class ReadPipeCallback; |
struct EpollEvent { |
EpollEvent(int events, bool is_epoll_wait) |
- : in_events(events), |
- out_ready_mask(0) { |
- } |
+ : in_events(events), out_ready_mask(0) {} |
- int in_events; // incoming events |
- int out_ready_mask; // the new event mask for ready list (0 means don't |
- // get on the ready list). This field is always |
- // initialized to 0 when the event is passed to |
- // OnEvent. |
+ int in_events; // incoming events |
+ int out_ready_mask; // the new event mask for ready list (0 means don't |
+ // get on the ready list). This field is always |
+ // initialized to 0 when the event is passed to |
+ // OnEvent. |
}; |
// Callbacks which go into EpollServers are expected to derive from this class. |
@@ -521,11 +519,13 @@ class EpollServer { |
entry.le_prev = NULL; |
} |
- CBAndEventMask(EpollCallbackInterface* cb, |
- int event_mask, |
- int fd) |
- : cb(cb), fd(fd), event_mask(event_mask), events_asserted(0), |
- events_to_fake(0), in_use(false) { |
+ CBAndEventMask(EpollCallbackInterface* cb, int event_mask, int fd) |
+ : cb(cb), |
+ fd(fd), |
+ event_mask(event_mask), |
+ events_asserted(0), |
+ events_to_fake(0), |
+ in_use(false) { |
entry.le_next = NULL; |
entry.le_prev = NULL; |
} |
@@ -637,8 +637,6 @@ class EpollServer { |
struct epoll_event events[], |
int events_size); |
- |
- |
// Summary: |
// An internal function for implementing the ready list. It adds a fd's |
// CBAndEventMask to the ready list. If the fd is already on the ready |
@@ -664,12 +662,11 @@ class EpollServer { |
// Custom hash function to be used by hash_set. |
struct AlarmCBHash { |
- size_t operator()(AlarmCB*const& p) const { |
+ size_t operator()(AlarmCB* const& p) const { |
return reinterpret_cast<size_t>(p); |
} |
}; |
- |
// TOOD(sushantj): Having this hash_set is avoidable. We currently have it |
// only so that we can enforce stringent checks that a caller can not register |
// the same alarm twice. One option is to have an implementation in which |
@@ -714,9 +711,7 @@ class EpollServer { |
public: |
EventRecorder() : num_records_(0), record_threshold_(10000) {} |
- ~EventRecorder() { |
- Clear(); |
- } |
+ ~EventRecorder() { Clear(); } |
// When a number of events equals the record threshold, |
// the collected data summary for all FDs will be written |
@@ -743,8 +738,7 @@ class EpollServer { |
void MaybeRecordAndClear() { |
++num_records_; |
- if ((num_records_ > record_threshold_) && |
- (record_threshold_ > 0)) { |
+ if ((num_records_ > record_threshold_) && (record_threshold_ > 0)) { |
LOG(INFO) << "\n" << *this; |
num_records_ = 0; |
Clear(); |
@@ -757,10 +751,9 @@ class EpollServer { |
MaybeRecordAndClear(); |
} |
- void RecordEpollWaitEvent(int timeout_in_ms, |
- int num_events_generated) { |
- EpollWaitOutput* ewo = new EpollWaitOutput(timeout_in_ms, |
- num_events_generated); |
+ void RecordEpollWaitEvent(int timeout_in_ms, int num_events_generated) { |
+ EpollWaitOutput* ewo = |
+ new EpollWaitOutput(timeout_in_ms, num_events_generated); |
debug_events_.push_back(ewo); |
MaybeRecordAndClear(); |
} |
@@ -810,13 +803,12 @@ class EpollServer { |
class FDMaskOutput : public DebugOutput { |
public: |
- FDMaskOutput(int fd, int mask, const char* function) : |
- fd_(fd), mask_(mask), function_(function) {} |
+ FDMaskOutput(int fd, int mask, const char* function) |
+ : fd_(fd), mask_(mask), function_(function) {} |
virtual void OutputToStream(ostream* os) const { |
- (*os) << "func: " << function_ |
- << "\tfd: " << fd_; |
+ (*os) << "func: " << function_ << "\tfd: " << fd_; |
if (mask_ != 0) { |
- (*os) << "\tmask: " << EventMaskToString(mask_); |
+ (*os) << "\tmask: " << EventMaskToString(mask_); |
} |
} |
int fd_; |
@@ -826,47 +818,59 @@ class EpollServer { |
class EpollWaitOutput : public DebugOutput { |
public: |
- EpollWaitOutput(int timeout_in_ms, |
- int num_events_generated) : |
- timeout_in_ms_(timeout_in_ms), |
- num_events_generated_(num_events_generated) {} |
+ EpollWaitOutput(int timeout_in_ms, int num_events_generated) |
+ : timeout_in_ms_(timeout_in_ms), |
+ num_events_generated_(num_events_generated) {} |
virtual void OutputToStream(ostream* os) const { |
(*os) << "timeout_in_ms: " << timeout_in_ms_ |
<< "\tnum_events_generated: " << num_events_generated_; |
} |
+ |
protected: |
int timeout_in_ms_; |
int num_events_generated_; |
}; |
struct Events { |
- Events() : |
- epoll_in(0), |
- epoll_pri(0), |
- epoll_out(0), |
- epoll_rdnorm(0), |
- epoll_rdband(0), |
- epoll_wrnorm(0), |
- epoll_wrband(0), |
- epoll_msg(0), |
- epoll_err(0), |
- epoll_hup(0), |
- epoll_oneshot(0), |
- epoll_et(0) {} |
+ Events() |
+ : epoll_in(0), |
+ epoll_pri(0), |
+ epoll_out(0), |
+ epoll_rdnorm(0), |
+ epoll_rdband(0), |
+ epoll_wrnorm(0), |
+ epoll_wrband(0), |
+ epoll_msg(0), |
+ epoll_err(0), |
+ epoll_hup(0), |
+ epoll_oneshot(0), |
+ epoll_et(0) {} |
void AssignFromMask(int event_mask) { |
- if (event_mask & EPOLLIN) ++epoll_in; |
- if (event_mask & EPOLLPRI) ++epoll_pri; |
- if (event_mask & EPOLLOUT) ++epoll_out; |
- if (event_mask & EPOLLRDNORM) ++epoll_rdnorm; |
- if (event_mask & EPOLLRDBAND) ++epoll_rdband; |
- if (event_mask & EPOLLWRNORM) ++epoll_wrnorm; |
- if (event_mask & EPOLLWRBAND) ++epoll_wrband; |
- if (event_mask & EPOLLMSG) ++epoll_msg; |
- if (event_mask & EPOLLERR) ++epoll_err; |
- if (event_mask & EPOLLHUP) ++epoll_hup; |
- if (event_mask & EPOLLONESHOT) ++epoll_oneshot; |
- if (event_mask & EPOLLET) ++epoll_et; |
+ if (event_mask & EPOLLIN) |
+ ++epoll_in; |
+ if (event_mask & EPOLLPRI) |
+ ++epoll_pri; |
+ if (event_mask & EPOLLOUT) |
+ ++epoll_out; |
+ if (event_mask & EPOLLRDNORM) |
+ ++epoll_rdnorm; |
+ if (event_mask & EPOLLRDBAND) |
+ ++epoll_rdband; |
+ if (event_mask & EPOLLWRNORM) |
+ ++epoll_wrnorm; |
+ if (event_mask & EPOLLWRBAND) |
+ ++epoll_wrband; |
+ if (event_mask & EPOLLMSG) |
+ ++epoll_msg; |
+ if (event_mask & EPOLLERR) |
+ ++epoll_err; |
+ if (event_mask & EPOLLHUP) |
+ ++epoll_hup; |
+ if (event_mask & EPOLLONESHOT) |
+ ++epoll_oneshot; |
+ if (event_mask & EPOLLET) |
+ ++epoll_et; |
}; |
friend ostream& operator<<(ostream& os, const Events& ev) { |
@@ -931,12 +935,8 @@ class EpollServer { |
int64 record_threshold_; |
}; |
- void ClearEventRecords() { |
- event_recorder_.Clear(); |
- } |
- void WriteEventRecords(ostream* os) const { |
- (*os) << event_recorder_; |
- } |
+ void ClearEventRecords() { event_recorder_.Clear(); } |
+ void WriteEventRecords(ostream* os) const { (*os) << event_recorder_; } |
mutable EventRecorder event_recorder_; |