]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/msg/async/Event.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / msg / async / Event.h
index 6736060ea1a0f1310f8622d936aee004f55038e5..5d6d04c9e8ecc48d915c98ce5d3a13ffd92b8f78 100644 (file)
@@ -173,7 +173,7 @@ class EventCenter {
   int notify_send_fd;
   NetHandler net;
   EventCallbackRef notify_handler;
-  unsigned idx;
+  unsigned center_id;
   AssociatedCenters *global_centers = nullptr;
 
   int process_time_events();
@@ -188,14 +188,14 @@ class EventCenter {
     external_num_events(0),
     driver(NULL), time_event_next_id(1),
     notify_receive_fd(-1), notify_send_fd(-1), net(c),
-    notify_handler(NULL), idx(0) { }
+    notify_handler(NULL), center_id(0) { }
   ~EventCenter();
   ostream& _event_prefix(std::ostream *_dout);
 
-  int init(int nevent, unsigned idx, const std::string &t);
+  int init(int nevent, unsigned center_id, const std::string &type);
   void set_owner();
   pthread_t get_owner() const { return owner; }
-  unsigned get_id() const { return idx; }
+  unsigned get_id() const { return center_id; }
 
   EventDriver *get_driver() { return driver; }
 
@@ -222,8 +222,8 @@ class EventCenter {
     func f;
     bool nonwait;
    public:
-    C_submit_event(func &&_f, bool nw)
-      : f(std::move(_f)), nonwait(nw) {}
+    C_submit_event(func &&_f, bool nowait)
+      : f(std::move(_f)), nonwait(nowait) {}
     void do_request(uint64_t id) override {
       f();
       lock.lock();
@@ -244,17 +244,16 @@ class EventCenter {
 
  public:
   template <typename func>
-  void submit_to(int i, func &&f, bool nowait = false) {
+  void submit_to(int i, func &&f, bool always_async = false) {
     ceph_assert(i < MAX_EVENTCENTER && global_centers);
     EventCenter *c = global_centers->centers[i];
     ceph_assert(c);
-    if (!nowait && c->in_thread()) {
-      f();
-      return ;
-    }
-    if (nowait) {
+    if (always_async) {
       C_submit_event<func> *event = new C_submit_event<func>(std::move(f), true);
       c->dispatch_event_external(event);
+    } else if (c->in_thread()) {
+      f();
+      return;
     } else {
       C_submit_event<func> event(std::move(f), false);
       c->dispatch_event_external(&event);