poco icon indicating copy to clipboard operation
poco copied to clipboard

Event reset does not work on linux

Open vsdownloader opened this issue 4 years ago • 2 comments

#include <unistd.h>
#include "Event.h"
Event e;
int main()
{
    std::thread t([]() {sleep(4); e.set(); }); t.detach();

    if (e.tryWait(2000))
        printf("ok\n");
    else {
        e.reset();
        printf("fail\n");
    }

    if (e.tryWait(3000))
        printf("ok\n"); 
    else
        printf("fail\n"); 

    //expect output  : fail  fail
    //actural output : fail  ok
    return 0;
}

vsdownloader avatar Jun 21 '21 07:06 vsdownloader

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Jun 22 '22 03:06 github-actions[bot]

I don't understand your expectation:

  • wait for 2 seconds, event is not set (it is reset automatically by default, so your explicit reset is unnecessary)
  • while waiting for 3 seconds, 4 second sleep in the thread expires and the event is set

fail ok is the expected outcome

aleks-f avatar Jun 22 '22 10:06 aleks-f

This issue is stale because it has been open for 365 days with no activity.

github-actions[bot] avatar Jun 24 '23 02:06 github-actions[bot]

This issue was closed because it has been inactive for 60 days since being marked as stale.

github-actions[bot] avatar Oct 04 '23 02:10 github-actions[bot]