Lines Matching refs:fde
38 void invoke_fde(struct fdevent* fde, unsigned events) { in invoke_fde() argument
39 if (auto f = std::get_if<fd_func>(&fde->func)) { in invoke_fde()
40 (*f)(fde->fd.get(), events, fde->arg); in invoke_fde()
41 } else if (auto f = std::get_if<fd_func2>(&fde->func)) { in invoke_fde()
42 (*f)(fde, events, fde->arg); in invoke_fde()
48 std::string dump_fde(const fdevent* fde) { in dump_fde() argument
50 if (fde->state & FDE_READ) { in dump_fde()
53 if (fde->state & FDE_WRITE) { in dump_fde()
56 if (fde->state & FDE_ERROR) { in dump_fde()
59 return android::base::StringPrintf("(fdevent %" PRIu64 ": fd %d %s)", fde->id, fde->fd.get(), in dump_fde()
73 fdevent* fde = &it->second; in Create() local
74 fde->id = fdevent_id_++; in Create()
75 fde->state = 0; in Create()
76 fde->fd = std::move(fd); in Create()
77 fde->func = func; in Create()
78 fde->arg = arg; in Create()
79 if (!set_file_block_mode(fde->fd, false)) { in Create()
83 LOG(ERROR) << "failed to set non-blocking mode for fd " << fde->fd.get(); in Create()
86 this->fdevent_set_.insert(fde); in Create()
87 this->Register(fde); in Create()
88 return fde; in Create()
91 unique_fd fdevent_context::Destroy(fdevent* fde) { in Destroy() argument
94 if (!fde) { in Destroy()
98 this->Unregister(fde); in Destroy()
100 unique_fd fd = std::move(fde->fd); in Destroy()
104 erased = this->fdevent_set_.erase(fde); in Destroy()
110 void fdevent_context::Add(fdevent* fde, unsigned events) { in Add() argument
112 Set(fde, fde->state | events); in Add()
115 void fdevent_context::Del(fdevent* fde, unsigned events) { in Del() argument
117 Set(fde, fde->state & ~events); in Del()
120 void fdevent_context::SetTimeout(fdevent* fde, std::optional<std::chrono::milliseconds> timeout) { in SetTimeout() argument
123 fde->timeout = timeout; in SetTimeout()
124 fde->last_active = std::chrono::steady_clock::now(); in SetTimeout()
133 for (const auto& [fd, fde] : this->installed_fdevents_) { in CalculatePollDuration()
135 auto timeout_opt = fde.timeout; in CalculatePollDuration()
137 auto deadline = fde.last_active + *timeout_opt; in CalculatePollDuration()
158 if (this->fdevent_set_.find(event.fde) != this->fdevent_set_.end()) { in HandleEvents()
159 invoke_fde(event.fde, event.events); in HandleEvents()
230 unique_fd fdevent_release(fdevent* fde) { in fdevent_release() argument
231 return fdevent_get_ambient()->Destroy(fde); in fdevent_release()
234 void fdevent_destroy(fdevent* fde) { in fdevent_destroy() argument
235 fdevent_get_ambient()->Destroy(fde); in fdevent_destroy()
238 void fdevent_set(fdevent* fde, unsigned events) { in fdevent_set() argument
239 fdevent_get_ambient()->Set(fde, events); in fdevent_set()
242 void fdevent_add(fdevent* fde, unsigned events) { in fdevent_add() argument
243 fdevent_get_ambient()->Add(fde, events); in fdevent_add()
246 void fdevent_del(fdevent* fde, unsigned events) { in fdevent_del() argument
247 fdevent_get_ambient()->Del(fde, events); in fdevent_del()
250 void fdevent_set_timeout(fdevent* fde, std::optional<std::chrono::milliseconds> timeout) { in fdevent_set_timeout() argument
251 fdevent_get_ambient()->SetTimeout(fde, timeout); in fdevent_set_timeout()