<< " time_id=" << time_event_next_id << ").";
}
-thread_local EventCenter* local_center = nullptr;
-
int EventCenter::init(int n, unsigned i)
{
// can't init multi times
cct->lookup_or_create_singleton_object<EventCenter::AssociatedCenters>(
global_centers, "AsyncMessenger::EventCenter::global_center");
assert(global_centers && !global_centers->centers[idx]);
- global_centers->centers[idx] = local_center = this;
- ldout(cct, 1) << __func__ << " idx=" << idx << " local_center=" << local_center << dendl;
+ global_centers->centers[idx] = this;
+ owner = pthread_self();
+ ldout(cct, 1) << __func__ << " idx=" << idx << " owner=" << owner << dendl;
}
int EventCenter::create_file_event(int fd, int mask, EventCallbackRef ctxt)
virtual int resize_events(int newsize) = 0;
};
-extern thread_local EventCenter* local_center;
-
-inline EventCenter* center() {
- return local_center;
-}
-
/*
* EventCenter maintain a set of file descriptor and handle registered events.
*/
CephContext *cct;
int nevent;
// Used only to external event
+ pthread_t owner;
std::mutex external_lock, file_lock;;
std::atomic_ulong external_num_events;
deque<EventCallbackRef> external_events;
// Used by external thread
void dispatch_event_external(EventCallbackRef e);
inline bool in_thread() const {
- return local_center == this;
+ return pthread_equal(pthread_self(), owner);
}
private: