We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
struct EventsImp { EventBase* base_; PollerBase* poller_; std::atomic exit_; int wakeupFds_[2]; ...... void EventsImp::init() { int r = pipe(wakeupFds_);
pipe 一般不是进程间通信用的吗?为什么会用在这里呢?有点奇怪,你也没有开多个进程啊? Channel* ch = new Channel(base_, wakeupFds_[0], kReadEvent);
通过下面来通知读取的对吧? void wakeup() { int r = write(wakeupFds_[1], "", 1); fatalif(r<=0, "write error wd %d %d %s", r, errno, strerror(errno)); } 不是很了解这套流程啊
The text was updated successfully, but these errors were encountered:
pipe的经典用法是进程间通信,这里用于线程间通信 epoll或监听各个fd的可读状态,当另一个线程往一个fd写入1字节时,另一个线程的epoll就会返回,就会处理队列中的任务,效果就是唤醒另一个线程,去处理队列中的任务
Sorry, something went wrong.
No branches or pull requests
struct EventsImp {
EventBase* base_;
PollerBase* poller_;
std::atomic exit_;
int wakeupFds_[2];
......
void EventsImp::init() {
int r = pipe(wakeupFds_);
pipe 一般不是进程间通信用的吗?为什么会用在这里呢?有点奇怪,你也没有开多个进程啊?
Channel* ch = new Channel(base_, wakeupFds_[0], kReadEvent);
通过下面来通知读取的对吧?
void wakeup() {
int r = write(wakeupFds_[1], "", 1);
fatalif(r<=0, "write error wd %d %d %s", r, errno, strerror(errno));
}
不是很了解这套流程啊
The text was updated successfully, but these errors were encountered: