Skip to content

Stuck event loop(event) in worker thread when adding more work into it(Mac OSX) #30

@lsergiy

Description

@lsergiy

Hello Nodepp dev. team! I have simple worker function I started using this code:

nodepp::worker::add( [&] () -> int {
        ...
        // initialization of http server done here
        ...
        nodepp::process::wait();
        return -1;
    } );

I tried to initialize http/ws servers and/or clients in it. Everything works OK.
Then I tried to add more workload into it using timer or periodic task. Basic timer:

        auto a_timer = nodepp::timer::interval( [&] () {
            ...
        }, 100 );

Or similar periodic task:

        nodepp::process::add( [&] () -> int {
            ...
            return 1; // return 1 -> will repeat the task
        } );

Any of these quick executing periodic tasks make even loop stuck in kevent call(Mac OSX):

inline int next() const {
        ...
        /* IO DETECTION */
        obj->idx=kevent( obj->pd, NULL, 0, &obj->ev, obj->ev.size(), &get_delay_tm() ); <<<< STUCK HERE
        if( obj->idx <= 0 ){ return 1; }
        ...

Perodic task can have empty code. So, my code does not affect to stuck behavior. Just starting timer or periodic function call is enough to reproduce the problem. You need to have at least one http server and at least one periodic task of any kind. Just start periodic task before starting http server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions