package a.c.b;

import java.util.HashSet;
import java.util.Set;
import java.util.Stack;

public class u {
    private static final String c = "UCarMessagePool";
    private static final int d = 20;
    private static final u e = new u();

    /* renamed from: a  reason: collision with root package name */
    private final Stack<s> f83a = new Stack<>();
    private final Set<Integer> b = new HashSet();

    private u() {
        for (int i = 0; i < 20; i++) {
            s a2 = s.a(true);
            this.f83a.add(a2);
            this.b.add(Integer.valueOf(a2.k()));
        }
    }

    public static u a() {
        return e;
    }

    public synchronized void a(s sVar) {
        if (sVar.p() && !this.b.contains(Integer.valueOf(sVar.k()))) {
            this.f83a.push(sVar);
            this.b.add(Integer.valueOf(sVar.k()));
        }
    }

    public synchronized s b() {
        if (this.f83a.isEmpty()) {
            k.a().d(c, "UCarMessage pool is empty, please check whether release message correctly or not");
            return s.a(false);
        }
        s pop = this.f83a.pop();
        this.b.remove(Integer.valueOf(pop.k()));
        return pop;
    }
}
