]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Event: remove time_lock which is no need
authorHaomai Wang <haomai@xsky.com>
Tue, 8 Mar 2016 06:31:19 +0000 (14:31 +0800)
committerHaomai Wang <haomai@xsky.com>
Wed, 29 Jun 2016 04:14:04 +0000 (12:14 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/msg/async/Event.cc
src/msg/async/Event.h

index e17db8aebb4de15a46ba0797d9ae426a7ed2663e..5bad77605f51b5de2118493f0311daebb130f8d2 100644 (file)
@@ -224,7 +224,7 @@ void EventCenter::delete_file_event(int fd, int mask)
 
 uint64_t EventCenter::create_time_event(uint64_t microseconds, EventCallbackRef ctxt)
 {
-  Mutex::Locker l(time_lock);
+  assert(in_thread());
   uint64_t id = time_event_next_id++;
 
   ldout(cct, 10) << __func__ << " id=" << id << " trigger after " << microseconds << "us"<< dendl;
@@ -242,7 +242,7 @@ uint64_t EventCenter::create_time_event(uint64_t microseconds, EventCallbackRef
 // TODO: Ineffective implementation now!
 void EventCenter::delete_time_event(uint64_t id)
 {
-  Mutex::Locker l(time_lock);
+  assert(in_thread());
   ldout(cct, 10) << __func__ << " id=" << id << dendl;
   if (id >= time_event_next_id)
     return ;
@@ -274,7 +274,6 @@ int EventCenter::process_time_events()
   clock_type::time_point now = clock_type::now();
   ldout(cct, 10) << __func__ << " cur time is " << now << dendl;
 
-  Mutex::Locker l(time_lock);
   while (!time_events.empty()) {
     auto it = time_events.begin();
     if (now >= it->first) {
@@ -284,9 +283,7 @@ int EventCenter::process_time_events()
       time_events.erase(it);
       ldout(cct, 10) << __func__ << " process time event: id=" << id << dendl;
       processed++;
-      time_lock.Unlock();
       cb->do_request(id);
-      time_lock.Lock();
     } else {
       break;
     }
@@ -311,9 +308,8 @@ int EventCenter::process_events(int timeout_microseconds)
     clock_type::time_point shortest;
     shortest = now + std::chrono::microseconds(timeout_microseconds); 
 
-    Mutex::Locker l(time_lock);
     auto it = time_events.begin();
-    if (it != time_events.end() && shortest > it->first) {
+    if (it != time_events.end() && shortest >= it->first) {
       ldout(cct, 10) << __func__ << " shortest is " << shortest << " it->first is " << it->first << dendl;
       shortest = it->first;
       trigger_time = true;
index b5fe2171f6e72897da0c389e848df748c112036e..9cf1a920deeb15cf4b2db7f7e7abdcce51419773 100644 (file)
@@ -107,7 +107,7 @@ class EventCenter {
   CephContext *cct;
   int nevent;
   // Used only to external event
-  Mutex external_lock, file_lock, time_lock;
+  Mutex external_lock, file_lock;
   atomic_t external_num_events;
   deque<EventCallbackRef> external_events;
   vector<FileEvent> file_events;
@@ -133,7 +133,6 @@ class EventCenter {
     cct(c), nevent(0),
     external_lock("AsyncMessenger::external_lock"),
     file_lock("AsyncMessenger::file_lock"),
-    time_lock("AsyncMessenger::time_lock"),
     external_num_events(0),
     driver(NULL), time_event_next_id(1),
     notify_receive_fd(-1), notify_send_fd(-1), net(c),