Skip to content
New issue

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

co:Event wait()不带参数,无法唤醒 #83

Closed
mosxuqian opened this issue Jul 11, 2020 · 1 comment
Closed

co:Event wait()不带参数,无法唤醒 #83

mosxuqian opened this issue Jul 11, 2020 · 1 comment

Comments

@mosxuqian
Copy link

mosxuqian commented Jul 11, 2020

#include "co/co.h"
#include "co/log.h"
#include "co/time.h"

co::Event ev;

DEF_bool(wait_alway, true, "false: wait for timeout, true wait alway");
void f2(){
    CLOG << "f2() start";
    bool r = true;
    if (FLG_wait_alway) {
        ev.wait();
    } else {
        r = ev.wait(1*1000);
    }
    CLOG << "f2() end: " << r;
}

void f3() {
    CLOG << "f3() start";
    ev.signal();
    CLOG << "f3() end";
}

int main(int argc, char** argv) {
    flag::init(argc, argv);
    log::init();
    go(f2);
    sleep::ms(100);
    go(f3);

    sleep::ms(2*1000);
    return 0;
}

运行结果1:
./test wait_alway=false

f2() start
f3() start
f3() end
f2() end: true

运行结果1:
./test wait_alway=true

f2() start
f3() start
f3() end
idealvin added a commit that referenced this issue Jul 11, 2020
@idealvin
Copy link
Owner

@mosxuqian
感谢反馈,已修复. 上次重构时,少打了一个 & 符号.
详情参考 commit fa20cc3ad...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants