54 {
55 if (is_shutdown_.load()) {
56 return false;
57 }
58
59 if (req.fd < 0 || req.callback == nullptr) {
60 AERROR <<
"input is invalid";
61 return false;
62 }
63
64 PollCtrlParam ctrl_param{};
65 ctrl_param.fd = req.fd;
66 ctrl_param.event.data.fd = req.fd;
67 ctrl_param.event.events = req.events;
68
69 {
70 WriteLockGuard<AtomicRWLock> lck(poll_data_lock_);
71 if (requests_.count(req.fd) == 0) {
72 ctrl_param.operation = EPOLL_CTL_ADD;
73 requests_[req.fd] = std::make_shared<PollRequest>();
74 } else {
75 ctrl_param.operation = EPOLL_CTL_MOD;
76 }
77 *requests_[req.fd] = req;
78 ctrl_params_[ctrl_param.fd] = ctrl_param;
79 }
80
81 Notify();
82 return true;
83}