Skip to content

The load balancing issue in Poco::ActiveThreadPool #4544

@siren186

Description

@siren186

Describe the bug
Each thread in Poco::ActiveThreadPool has its own Poco::NotificationQueue.
If I have 2 types of Runnable like this:

class LongTimeTask : public Poco::Runnable {
    void run() {
        sleep(2 * 60 * 1000);
    }
};

class ShortTimeTask : public Poco::Runnable {
    void run() {
        sleep(1);
    }
};

int capacity = 2;
Poco::ActiveThreadPool pool(capacity);

for (int i = 0; i < 10; i++) {
    pool.start(new LongTimeTask); // [BUG!!!] all long time task will enqueue to thread#1
    pool.start(new ShortTimeTask); // [BUG!!!] all short time task will enqueue to thread#2
}

thread#2 will always in idle, and thread#1 will always in busy !!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions