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)

        }

  • 相关阅读:
    gps示例代码
    UART 串口示例代码
    Linux soft lockup 和 hard lockup
    Linux嵌入式kgdb调试环境搭建
    Linux嵌入式GDB调试环境搭建
    Linux-workqueue讲解
    USB之hub3
    USB之设备插入波形变化2
    我运营公众号这一个月
    从12306帐号泄漏谈用户密码安全
  • 原文地址:https://www.cnblogs.com/feng9exe/p/9441238.html
Copyright © 2011-2022 走看看