Browse Source

Rename to stop

onevcat 10 years ago
parent
commit
b7c0899521
2 changed files with 7 additions and 2 deletions
  1. 6 1
      Sources/ImagePrefetcher.swift
  2. 1 1
      Tests/KingfisherTests/ImagePrefetcherTests.swift

+ 6 - 1
Sources/ImagePrefetcher.swift

@@ -176,8 +176,13 @@ public class ImagePrefetcher {
     /**
      Stop current downloading progress, and cancel any future prefetching activity that might be occuring.
      */
-    public func cancel() {
+    public func stop() {
         dispatch_async_safely_to_main_queue {
+            
+            if self.finished {
+                return
+            }
+            
             self.cancelled = true
             self.tasks.forEach { (_, task) -> () in
                 task.cancel()

+ 1 - 1
Tests/KingfisherTests/ImagePrefetcherTests.swift

@@ -109,7 +109,7 @@ class ImagePrefetcherTests: XCTestCase {
         prefetcher.maxConcurrentDownloads = maxConcurrentCount
         
         prefetcher.start()
-        prefetcher.cancel()
+        prefetcher.stop()
         
         let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
         dispatch_after(delayTime, dispatch_get_main_queue()) {