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

Commit 7006a0e1 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add empty, dump methods to BlockingQueue" into main

parents 9af0a068 287f9986
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include <input/PrintTools.h>
#include <condition_variable>
#include <functional>
#include <list>
@@ -126,11 +127,21 @@ public:
     * Primary used for debugging.
     * Does not block.
     */
    size_t size() {
    size_t size() const {
        std::scoped_lock lock(mLock);
        return mQueue.size();
    }

    bool empty() const {
        std::scoped_lock lock(mLock);
        return mQueue.empty();
    }

    std::string dump(std::string (*toString)(const T&) = constToString) const {
        std::scoped_lock lock(mLock);
        return dumpContainer(mQueue, toString);
    }

private:
    const std::optional<size_t> mCapacity;
    /**
@@ -140,7 +151,7 @@ private:
    /**
     * Lock for accessing and waiting on elements.
     */
    std::mutex mLock;
    mutable std::mutex mLock;
    std::list<T> mQueue GUARDED_BY(mLock);
};