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

Commit d8840587 authored by Chalard Jean's avatar Chalard Jean
Browse files

Fix an issue in TrackRecord.

TrackRecord<T> implements List<T> but also has an add(T)
method which conflicts with List<T>#add as it has a different
return type. As nobody is using the return value of this now,
use the signature of List<T>#add to remove the problem.

Bug: 153613718
Test: NetworkStackTests FrameworksNetTests
Change-Id: Ie9eb4d7158e9583d4052e86f87062e3032b023e3
parent 1162d1cd
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))