private static DispatchQueue createMainQueue() { try { // this call will fail when running a unit test // we would allow that and make test responsible for setting the implementation return new SerialDispatchQueue(Looper.getMainLooper(), "Main"); } catch (Exception e) { return null; } }
/** * Creates a background queue with specified <code>name</code> and dispatch type. */ public static DispatchQueue createBackgroundQueue(String name, DispatchQueueType type) { if (type == DispatchQueueType.Serial) { return new SerialDispatchQueue(name); } if (type == DispatchQueueType.Concurrent) { return new ConcurrentDispatchQueue(name); } throw new IllegalArgumentException("Unexpected queue type: " + type); }