程嶏清单 17-12.txt

来自「< linux网络编程工具>>配套源码」· 文本 代码 · 共 22 行

TXT
22
字号
程序清单17-12:event_loop.pl
sub event_loop {
        my ($pkg, $loop_count) = @_;
    my ($conn, $r, $w, $rset, $wset);
        while (1) {
            # Quit the loop if no handles left to process
      last unless ($rd_handles->count() || $wt_handles->count());
            ($rset, $wset) =
                IO::Select->select ($rd_handles, $wt_handles, 
                                    undef, undef);
    foreach $r (@$rset) {
                  &{$rd_callbacks{$r}} ($r) if exists $rd_callbacks{$r};
    }
    foreach $w (@$wset) {
                  &{$wt_callbacks{$w}}($w) if exists $wt_callbacks{$w};
    }
            if (defined($loop_count)) {
            last unless --$loop_count;
            }
        }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?