Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e19ccfad authored by John Reck's avatar John Reck Committed by Android (Google) Code Review
Browse files

Merge "Fix race condition in CommonPool destructor by just leaking it instead" into main

parents d604a4dc be94fdb3
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -52,9 +52,13 @@ CommonPool::CommonPool() : CommonPoolBase() {
    }
}

CommonPool::~CommonPool() {
    LOG_ALWAYS_FATAL("CommonPool can't be stopped");
}

CommonPool& CommonPool::instance() {
    static CommonPool pool;
    return pool;
    static CommonPool* pool = new CommonPool();
    return *pool;
}

void CommonPool::post(Task&& task) {
@@ -80,7 +84,7 @@ void CommonPool::enqueue(Task&& task) {

void CommonPool::workerLoop() {
    std::unique_lock lock(mLock);
    while (!mIsStopping) {
    while (true) {
        if (!mWorkQueue.hasWork()) {
            mWaitingThreads++;
            mCondition.wait(lock);
+1 −5
Original line number Diff line number Diff line
@@ -108,10 +108,7 @@ private:
    static CommonPool& instance();

    CommonPool();
    ~CommonPool() {
        mIsStopping = true;
        mCondition.notify_all();
    }
    ~CommonPool();

    void enqueue(Task&&);
    void doWaitForIdle();
@@ -124,7 +121,6 @@ private:
    std::condition_variable mCondition;
    int mWaitingThreads = 0;
    ArrayQueue<Task, QUEUE_SIZE> mWorkQueue;
    std::atomic_bool mIsStopping = false;
};

}  // namespace uirenderer