NSOperationQueue

  1. Getting Specific Operation Queues
  2. Managing Operations in the Queue
  3. Managing the Execution of Operations
  4. Suspending Operations
  5. Configuring the Queue

NSOperationQueue是NSOperation的操作队列,主要用于管理NSOperation子类的执行。NSOperationQueue是按照顺序执行相关NSOperation操作。

1 Getting Specific Operation Queues

/// 获取当前队列
@available(iOS 4.0, *)
public class func currentQueue() -> NSOperationQueue?

/// 获取主队列
@available(iOS 4.0, *)
public class func mainQueue() -> NSOperationQueue

2 Managing Operations in the Queue

/// 添加一个NSOperation
public func addOperation(op: NSOperation)

/// 添加NSOperation组到队列中,并记录是否等待。
///
/// - parameter ops : [NSOperation]
/// - parameter wait : 是否等待其他操作执行完毕
///
/// - returns: void
@available(iOS 4.0, *)
public func addOperations(ops: [NSOperation], waitUntilFinished wait: Bool)

/// 添加block操作到队列中
@available(iOS 4.0, *)
public func addOperationWithBlock(block: () -> Void)

/// 获取所有操作
public var operations: [NSOperation] { get }

/// 队列中的队列数
@available(iOS 4.0, *)
public var operationCount: Int { get }

/// 取消所有队列
public func cancelAllOperations()

/// 阻塞当前线程,直到所有的操作执行完毕
public func waitUntilAllOperationsAreFinished()    

3 Managing the Execution of Operations

/// 队列的级别
@available(iOS 8.0, *)
public var qualityOfService: NSQualityOfService

/// 同时执行的最大操作数
public var maxConcurrentOperationCount: Int

4 Suspending Operations

/// 是否暂停队列
public var suspended: Bool

5 Configuring the Queue

/// 队列名
@available(iOS 4.0, *)
public var name: String?

/// 操作队列的线程
@available(iOS 8.0, *)
unowned(unsafe) public var underlyingQueue: dispatch_queue_t?

 


Appendix

Sample Code

Swift

NSOperationQueue Class Reference

Concurrency Programming Guide

Simple and Reliable Threading with NSOperation

Revision History

时间描述
2016-03-09博文完成

CSDN:http://blog.csdn.net/y550918116j

GitHub:https://github.com/937447974/Blog

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值