You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this case the output will be the following one: `[[A & B -> completionHandler] -> C] -> completionHandler`.
176
177
177
-
### Queue States
178
+
### Available Queue States
178
179
179
180
There are a few method to handle the queue states.
180
181
@@ -211,7 +212,34 @@ There are a few method to handle the queue states.
211
212
> [!IMPORTANT]
212
213
> This function means that the queue will blocks the current thread until all `Operation`s are finished.
213
214
214
-
### Synchronous Queue
215
+
### Control Operation States
216
+
217
+
You can control the `ConcurrentOperation` states by calling `pause()`, `resume()`, `cancel()`.
218
+
219
+
> [!NOTE]
220
+
> If you use a `Queuer` object with all `ConcurrentOperation` objects inside to manage your queue, you should avoid calling them directly on the `ConcurrentOperation` object, but you should call them on the `Queuer` one. The `Queuer` object will handle the `ConcurrentOperation` states automatically.
221
+
222
+
1. Pause a `ConcurrentOperation`:
223
+
224
+
```swift
225
+
concurrentOperation.pause()
226
+
```
227
+
228
+
2. Resume a `ConcurrentOperation`:
229
+
230
+
```swift
231
+
concurrentOperation.resume()
232
+
```
233
+
234
+
3. Cancel a `ConcurrentOperation`:
235
+
236
+
```swift
237
+
concurrentOperation.cancel()
238
+
```
239
+
240
+
For convenience, you can set closures to the `ConcurrentOperation` object to handle the states with `onPause`, `onResume`, and `onCancel` properties. They will be called when the `ConcurrentOperation` is paused, resumed, or canceled.
241
+
242
+
### Use a Synchronous Queue
215
243
216
244
Setting the `maxConcurrentOperationCount` property of a queue to `1` will make you sure that only one task at a time will be executed.
> If you don't set `manualFinish` to `true`, your `Operation` will finish before the async task is completed.
317
345
318
-
### Scheduler
346
+
### Set Up a Scheduler
319
347
320
348
A `Scheduler` is a struct that uses the GDC's `DispatchSourceTimer` to create a timer that can execute functions with a specified interval and quality of service.
321
349
@@ -340,7 +368,7 @@ With `timer` property you can access to all `DispatchSourceTimer` properties and
340
368
schedule.timer.cancel()
341
369
```
342
370
343
-
### Semaphore
371
+
### Use a Semaphore
344
372
345
373
A `Semaphore` is a struct that uses the GCD's `DispatchSemaphore` to create a semaphore on the function and wait until it finish its job.
0 commit comments