zzm.java 2.94 KB
package com.google.android.gms.internal;

import android.os.Handler;
import android.os.Looper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.atomic.AtomicInteger;

public class zzm
{
  final Map<String, Queue<zzl<?>>> a = new HashMap();
  final Set<zzl<?>> b = new HashSet();
  final PriorityBlockingQueue<zzl<?>> c = new PriorityBlockingQueue();
  List<Object> d = new ArrayList();
  private AtomicInteger e = new AtomicInteger();
  private final PriorityBlockingQueue<zzl<?>> f = new PriorityBlockingQueue();
  private final zzb g;
  private final zzg h;
  private final zzo i;
  private zzh[] j;
  private zzc k;
  
  public zzm(zzb paramzzb, zzg paramzzg)
  {
    this(paramzzb, paramzzg, 4);
  }
  
  public zzm(zzb paramzzb, zzg paramzzg, int paramInt)
  {
    this(paramzzb, paramzzg, paramInt, new zzf(new Handler(Looper.getMainLooper())));
  }
  
  public zzm(zzb paramzzb, zzg paramzzg, int paramInt, zzo paramzzo)
  {
    this.g = paramzzb;
    this.h = paramzzg;
    this.j = new zzh[paramInt];
    this.i = paramzzo;
  }
  
  public int getSequenceNumber()
  {
    return this.e.incrementAndGet();
  }
  
  public void start()
  {
    stop();
    this.k = new zzc(this.c, this.f, this.g, this.i);
    this.k.start();
    int m = 0;
    while (m < this.j.length)
    {
      zzh localzzh = new zzh(this.f, this.h, this.g, this.i);
      this.j[m] = localzzh;
      localzzh.start();
      m += 1;
    }
  }
  
  public void stop()
  {
    if (this.k != null) {
      this.k.quit();
    }
    int m = 0;
    while (m < this.j.length)
    {
      if (this.j[m] != null) {
        this.j[m].quit();
      }
      m += 1;
    }
  }
  
  public <T> zzl<T> zze(zzl<T> paramzzl)
  {
    paramzzl.zza(this);
    synchronized (this.b)
    {
      this.b.add(paramzzl);
      paramzzl.zza(getSequenceNumber());
      paramzzl.zzc("add-to-queue");
      if (!paramzzl.zzn())
      {
        this.f.add(paramzzl);
        return paramzzl;
      }
    }
    for (;;)
    {
      String str;
      synchronized (this.a)
      {
        str = paramzzl.zzg();
        if (this.a.containsKey(str))
        {
          Queue localQueue = (Queue)this.a.get(str);
          ??? = localQueue;
          if (localQueue == null) {
            ??? = new LinkedList();
          }
          ((Queue)???).add(paramzzl);
          this.a.put(str, ???);
          if (zzt.DEBUG) {
            zzt.zza("Request for cacheKey=%s is in flight, putting on hold.", new Object[] { str });
          }
          return paramzzl;
        }
      }
      this.a.put(str, null);
      this.c.add(paramzzl);
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/android/gms/internal/zzm.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */