iOS utility class to manage global dispatch queue.

Overview

YYDispatchQueuePool

License MIT  Carthage compatible  CocoaPods  CocoaPods  Support  Build Status

iOS utility class to manage global dispatch queue.
(It's a component of YYKit)

When use a concurrent queue to execute lots of blocks, I met this problem in some situation:

When some block is locked, the concurrent queue may create lots of thread and may block the main thread. Use a global serial queue pool to avoid it.

Usage

// Get a serial queue from global queue pool
dispatch_queue_t queue = YYDispatchQueueGetForQOS(NSQualityOfServiceUtility);

// Create a serial queue pool
YYDispatchQueuePool *pool = [[YYDispatchQueuePool alloc] initWithName:@"file.read" queueCount:5 qos:NSQualityOfServiceBackground];
dispatch_queue_t queue = [pool queue];

Installation

CocoaPods

  1. Add pod 'YYDispatchQueuePool' to your Podfile.
  2. Run pod install or pod update.
  3. Import <YYDispatchQueuePool/YYDispatchQueuePool.h>.

Carthage

  1. Add github "ibireme/YYDispatchQueuePool" to your Cartfile.
  2. Run carthage update --platform ios and add the framework to your project.
  3. Import <YYDispatchQueuePool/YYDispatchQueuePool.h>.

Manually

  1. Download all the files in the YYDispatchQueuePool subdirectory.
  2. Add the source files to your Xcode project.
  3. Import YYDispatchQueuePool.h.

Documentation

Full API documentation is available on CocoaDocs.
You can also install documentation locally using appledoc.

Requirements

This library requires iOS 6.0+ and Xcode 8.0+.

License

YYDispatchQueuePool is provided under the MIT license. See LICENSE file for details.



中文介绍

iOS 全局并发队列管理工具。
(该项目是 YYKit 组件之一)

当用 concurrent queue 来执行大量 block 时,有时会遇到下面这种情况:

当某个 block 所在线程被锁住时,concurrent queue 会创建大量线程以至于占用了过多资源而影响到主线程。这里可以用一个全局的 serial queue pool 来尽量控制全局线程数。

用法

// 从全局的 queue pool 中获取一个 queue
dispatch_queue_t queue = YYDispatchQueueGetForQOS(NSQualityOfServiceUtility);
	
// 创建一个新的 serial queue pool
YYDispatchQueuePool *pool = [[YYDispatchQueuePool alloc] initWithName:@"file.read" queueCount:5 qos:NSQualityOfServiceBackground];
dispatch_queue_t queue = [pool queue];

安装

CocoaPods

  1. 在 Podfile 中添加 pod 'YYDispatchQueuePool'
  2. 执行 pod installpod update
  3. 导入 <YYDispatchQueuePool/YYDispatchQueuePool.h>。

Carthage

  1. 在 Cartfile 中添加 github "ibireme/YYDispatchQueuePool"
  2. 执行 carthage update --platform ios 并将生成的 framework 添加到你的工程。
  3. 导入 <YYDispatchQueuePool/YYDispatchQueuePool.h>。

手动安装

  1. 下载 YYDispatchQueuePool 文件夹内的所有内容。
  2. 将 YYDispatchQueuePool 内的源文件添加(拖放)到你的工程。
  3. 导入 YYDispatchQueuePool.h

文档

你可以在 CocoaDocs 查看在线 API 文档,也可以用 appledoc 本地生成文档。

系统要求

该项目最低支持 iOS 6.0Xcode 8.0

许可证

YYDispatchQueuePool 使用 MIT 许可证,详情见 LICENSE 文件。

相关文章

iOS 保持界面流畅的技巧

You might also like...
A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.

MJExtension A fast, convenient and nonintrusive conversion framework between JSON and model. 转换速度快、使用简单方便的字典转模型框架 📜 ✍🏻Release Notes: more details Co

A simple class that wraps the process of saving or loading a struct or class into a single file

EZFile This is a simple class that wraps the process of saving or loading a stru

Xcode Plugin helps you find missing methods in your class header, protocols, and super class, also makes fast inserting.

FastStub-Xcode Life is short, why waste it on meaningless typing? What is it? A code generating feature borrowed from Android Studio. FastStub automat

Objective-C utility class for storing data securely in the key chain.

Lockbox Lockbox is an Objective-C utility class for storing data securely in the keychain. Use it to store small, sensitive bits of data securely. Loo

⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes
⌨️ Add user-customizable global keyboard shortcuts to your macOS app in minutes

This package lets you add support for user-customizable global keyboard shortcuts to your macOS app in minutes. It's fully sandbox and Mac App Store c

This is an Instagram clone with a custom Parse backend that allows a user to post photos, view a global photos feed, and add comments!
This is an Instagram clone with a custom Parse backend that allows a user to post photos, view a global photos feed, and add comments!

Parstagram - Part II This is an Instagram clone with a custom Parse backend that allows a user to post photos, view a global photos feed, and add comm

Condense string literals into global variables.

Gettysburg This is an implementation of the SAX interface. API Documentation Documentation of the API can be found here: Gettysburg API A note on Char

This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system's image library.

title description Camera Take pictures with the device camera. AppVeyor Travis CI cordova-plugin-camera This plugin defines a global navigator.camera

Global formula editor with swift

Koshiki (With auto-completion of Typinator. )

Commonly available global error type packages

ErrorKit 일반적으로 사용 할 수 있는 전역 오류 타입 패키지. Requirements Xcode 13.2.1+ Swift 5.5+ Ins

A Swifty API for global macOS hotkeys.

A Swifty API for global macOS hotkeys. Install Add the following dependency to your Package.swift file: .package(url: "https://github.com/jordanbaird/

A computer-vision-driven app for detecting and mapping smog in public roads. Crowdsourcing is rewarded with NFTs. Uber Global Hackathon.
A computer-vision-driven app for detecting and mapping smog in public roads. Crowdsourcing is rewarded with NFTs. Uber Global Hackathon.

Smogify Detecting smog using ML and rewarding users with NFTs About The Project app in action: https://youtu.be/awJrP-sHb_I Under the growing uncertai

CCMQ is a message queue framework built for iOS

CCMQ CCMQ是基于MMAP开发的适用于iOS的消息队列框架 基本特性介绍 1.到达性和顺序性: CCMQ会确保消息一定能够发送到订阅者,CCMQ拥有串行和并行队列,串行队列会确保消息能够按照顺序发送顺序到达订阅者,并行队列则能够批量进行消息发送,但同一批次的消息到达顺序不能保证。 2.ACK机

Swift-Misc-Utility - Taking the misc out of General Utility so that General only defines the namespace

Swift-Misc-Utility Everything extra that used to be in Swift-General-Utility has

A real-time, votable, democratized music queue on iPad and iPhone using Spotify
A real-time, votable, democratized music queue on iPad and iPhone using Spotify

Queue'd Music Queue'd is the best way to enjoy music with your friends. Add your favorite songs to a shared music queue at your favorite bars, restaur

ClassicPhotos is a TableView App demos how to optimize image download and filter with operation queue.
ClassicPhotos is a TableView App demos how to optimize image download and filter with operation queue.

ClassicPhotos ClassicPhotos is a TableView App demos how to optimize image download and filter with operation queue. With Operation and Operation Queu

A protocol-centric, type and queue safe key-value workflow.
A protocol-centric, type and queue safe key-value workflow.

Light-weight, strict protocol-first styled PropertyKit helps you to easily and safely handle guaranteed values, keys or types on various situations of

A Generic Priority Queue in Pure Swift

SwiftPriorityQueue SwiftPriorityQueue is a pure Swift (no Cocoa) implementation of a generic priority queue data structure, appropriate for use on all

Queue management system for AVSpeechSynthesizer

QHSpeechSynthesizerQueue Queue management system for AVSpeechSynthesizer Installation Cocoapods Add this to your Podfile: pod 'QHSpeechSynthesizerQueu

Comments
  • 这个确定可以支持iOS6以上吗

    这个确定可以支持iOS6以上吗

    我看了下NSQualityOfServic这个枚举,在iOS8及以上的版本才能用啊

    typedef NS_ENUM(NSInteger, NSQualityOfService) {
        /* UserInteractive QoS is used for work directly involved in providing an interactive UI such as processing events or drawing to the screen. */
        NSQualityOfServiceUserInteractive = 0x21,
    
        /* UserInitiated QoS is used for performing work that has been explicitly requested by the user and for which results must be immediately presented in order to allow for further user interaction.  For example, loading an email after a user has selected it in a message list. */
        NSQualityOfServiceUserInitiated = 0x19,
    
        /* Utility QoS is used for performing work which the user is unlikely to be immediately waiting for the results.  This work may have been requested by the user or initiated automatically, does not prevent the user from further interaction, often operates at user-visible timescales and may have its progress indicated to the user by a non-modal progress indicator.  This work will run in an energy-efficient manner, in deference to higher QoS work when resources are constrained.  For example, periodic content updates or bulk file operations such as media import. */
        NSQualityOfServiceUtility = 0x11,
    
        /* Background QoS is used for work that is not user initiated or visible.  In general, a user is unaware that this work is even happening and it will run in the most efficient manner while giving the most deference to higher QoS work.  For example, pre-fetching content, search indexing, backups, and syncing of data with external systems. */
        NSQualityOfServiceBackground = 0x09,
    
        /* Default QoS indicates the absence of QoS information.  Whenever possible QoS information will be inferred from other sources.  If such inference is not possible, a QoS between UserInitiated and Utility will be used. */
        NSQualityOfServiceDefault = -1
    } NS_ENUM_AVAILABLE(10_10, 8_0);
    
    opened by lexiaoyao20 2
  • 这句代码是不是没用?

    这句代码是不是没用?

    #define MAX_QUEUE_COUNT 32

    int count = (int)[NSProcessInfo processInfo].activeProcessorCount; count = count < 1 ? 1 : count > MAX_QUEUE_COUNT ? MAX_QUEUE_COUNT : count;

    iPhone在代码上获取处理器个数count为2,而且这个count应该不会超过32吧?

    opened by FlyOceanFish 0
  • 在Objective-C++项目里报错

    在Objective-C++项目里报错

    项目是Objective-C++,有很多.mm文件。手动引入后报这个错误,手动把.h.m拖到工程里面的。

    Undefined symbols for architecture arm64: "YYDispatchQueueGetForQOS(NSQualityOfService)", referenced from: -[CameraManager queue] in CameraManager.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

    opened by ChokWah 0
  • 求问导致多个NSThread的情况

    求问导致多个NSThread的情况

    你好,请问 dispatch_async(self.mainQueue, ^{ dispatch_sync(self.subQueue, ^{ NSLog(@"%@", [NSThread currentThread]); 这种,chatMainQueue使用YYDispatchQueuePool的queue,或者使用一个SERIAL的queue,是有创建新的NSThread,这种好像系统控制了资源分配,可是当处理比较长,创建的NSThread越多,内存问题就越大。不知是否有可行办法。 实现非主线程的串行队列,也是想控制其在一个或者固定几个NSThread执行,然后再回到主线程更新UI。

    opened by chenqihui 0
Owner
null
SwiftRingBuffer - RingBuffer aka Circular Queue

Swift Ring Buffer Ring Buffer aka Circular Queue Ussage var queue = CircularQueu

null 1 Feb 1, 2022
Grand Central Dispatch simplified with swift.

GCDKit GCDKit is Grand Central Dispatch simplified with Swift. for Swift 1.2: Use version 1.0.1 for Swift 2.1 / 2.2: Use the master branch Introductio

John Estropia 317 Dec 6, 2022
Syntactic sugar in Swift for asynchronous dispatches in Grand Central Dispatch

Async Now more than syntactic sugar for asynchronous dispatches in Grand Central Dispatch (GCD) in Swift Async sugar looks like this: Async.userInitia

Tobias Due Munk 4.6k Dec 27, 2022
Chronos is a collection of useful Grand Central Dispatch utilities.

Chronos is a collection of useful Grand Central Dispatch utilities. If you have any specific requests or ideas for new utilities, don't hesitate to create a new issue.

Comyar Zaheri 248 Sep 19, 2022
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).

Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD). It allows you to create any asynchronous and synchronous task easily, all managed by a queue, with just a few lines.

Fabrizio Brancati 1k Dec 2, 2022
A Task Queue Class developed in Swift (by Marin Todorov)

TaskQueue Table of Contents Intro Installation CocoaPods Carthage Simple Examples Synchronous tasks Asynchronous tasks Serial and Concurrent Tasks GCD

Marin Todorov 677 Jan 3, 2023
A library and CLI Utility to manage NVRAM Stuff, written in Swift.

NVRAMKit A Library and CLI Utility to manage NVRAM Stuff, written in Swift. Library Adding Library to Project Simply add this line to the dependencies

Serena 7 Sep 25, 2022
ZipArchive is a simple utility class for zipping and unzipping files on iOS, macOS and tvOS.

SSZipArchive ZipArchive is a simple utility class for zipping and unzipping files on iOS, macOS and tvOS. Unzip zip files; Unzip password protected zi

ZipArchive 5.2k Jan 2, 2023
iOS utility class allows you to access keyboard view and track keyboard animation.

YYKeyboardManager iOS utility class allows you to access keyboard view and track keyboard animation. (It was used by YYText) Compatibility iPhone / iP

null 480 Nov 17, 2022
AREarthObservatory - A minimal iOS AR app that visualizes time-series changes in the global environment based on data from NASA satellites

A minimal iOS AR app that visualizes time-series changes in the global environment based on data from NASA satellites

Yasuhito Nagatomo 3 Aug 11, 2022