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

Commit 9b2ec350 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Fix an issue in TrackRecord. am: 768d586c

Change-Id: I02b0c3aab14e7f29d534638a97332d468191a9c5
parents 7b0859b1 768d586c
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -27,9 +27,10 @@ import kotlin.concurrent.withLock
 */
interface TrackRecord<E> : List<E> {
    /**
     * Adds an element to this queue, waking up threads waiting for one. Returns the element.
     * Adds an element to this queue, waking up threads waiting for one. Returns true, as
     * per the contract for List.
     */
    fun add(e: E): TrackRecord<E>
    fun add(e: E): Boolean

    /**
     * Returns the first element after {@param pos}, possibly blocking until one is available, or
@@ -91,12 +92,12 @@ class ArrayTrackRecord<E> : TrackRecord<E> {
    }

    // TrackRecord<E> implementation
    override fun add(e: E): ArrayTrackRecord<E> {
    override fun add(e: E): Boolean {
        lock.withLock {
            elements.add(e)
            condition.signalAll()
        }
        return this
        return true
    }
    override fun poll(timeoutMs: Long, pos: Int, predicate: (E) -> Boolean) = lock.withLock {
        elements.getOrNull(pollForIndexReadLocked(timeoutMs, pos, predicate))