zoukankan      html  css  js  c++  java
  • 多线程-工作组模式

    来自:https://github.com/onevcat/Kingfisher

    任务计数模式

        func testDownloadMultipleImages() {

            let expectation = self.expectation(description: "wait for all downloading finish")

            

            let group = DispatchGroup()

            

            for URLString in testKeys {

                if let url = URL(string: URLString) {

                    group.enter()

                    _ = stubRequest("GET", URLString).andReturn(200)?.withBody(testImageData)

                    downloader.downloadImage(with: url, options: nil, progressBlock: { (receivedSize, totalSize) -> Void in

                        

                    }, completionHandler: { (image, error, imageURL, data) -> Void in

                        XCTAssert(image != nil, "Download should be able to finished for URL: (String(describing: imageURL)).")

                        group.leave()

                    })

                }

            }

            

            group.notify(queue: .main, execute: expectation.fulfill)

            waitForExpectations(timeout: 5, handler: nil)

        }

  • 相关阅读:
    算法竞赛进阶指南 0.1
    补题 : 过分的谜题
    矩阵快速幂【模板】
    10774: matrix
    火车进出栈问题 【求卡特兰数】
    [最小割]StoerWagner算法
    安装、使用sklearn
    [线段树]跳蚤
    [树形dp][换根]Maximum White Subtree
    [组合数学]Many Many Paths
  • 原文地址:https://www.cnblogs.com/feng9exe/p/9441238.html
Copyright © 2011-2022 走看看