Comments (12)
Hi @marinofaggiana, thanks 😄
What kind of examples do you need?
If you are looking for a ConcurrentOperation
subclass, you can take a look at the SynchronousOperation subclass implementation.
Let me know if you need anything else!
from queuer.
Hi @FabrizioBrancati, tanks for your response, with semaphore? I need of a maxConcurrentOperationCount = 5 but I don't understand your implementation... can you explain a small example for this ?
from queuer.
You can find an example on the README or inside the SemaphoreTests.swift file in the Tests
folder.
If it's not enough, what's your use case?
from queuer.
Thanks @FabrizioBrancati I need e.g. of read 1000 files with a async func e.g.
func download (filename: string, completion: @escaping (_ errorCode: Int) -> ())
but with max 5 download in execution, we already have a class for this but I am interested to try with you lib if can streamline the code :-)
from queuer.
Why do you need a semaphore?
You can just create 1000 ConcurrentOperation
s and adding them to a queue by setting maxConcurrentOperationCount
property to 5
.
They will be executed by 5 until the end.
If you want, you can subclass ConcurrentOperation
to create your custom operation to be added to the queue.
from queuer.
yes, of better NO, we have look you code and now is clear. thanks
from queuer.
Are you sure?
Can I close the issue? 😄
from queuer.
Can be improved?
import Foundation
import Queuer
@objc class NCOperationQueue: NSObject {
@objc public static let shared: NCOperationQueue = {
let instance = NCOperationQueue()
return instance
}()
let downloadQueue = Queuer(name: "downloadQueue", maxConcurrentOperationCount: 5, qualityOfService: .default)
@objc func download(fileName: String) {
downloadQueue.addOperation(NCOperationDownload.init(filename: filename))
}
}
class NCOperationDownload: ConcurrentOperation {
private var filename: String
init(filename: String) {
self.filename = filename
}
override func start() {
NCNetworking.shared.download(filename: self.filename) { (_) in
self.finish()
}
}
}
from queuer.
You can take a look at the RequestOperation that was implemented in the first version of Queuer.
There are a lot of ways to improve your code 😉
from queuer.
Did you take a look at the RequestOperation source file?
from queuer.
Hi @marinofaggiana news about this? 😄
from queuer.
Hi @FabrizioBrancati sorry for the long time, all ok, we can close this.
from queuer.
Related Issues (20)
- Handle Retry HOT 5
- The Queuer watch framework deployment target should be 3.0 or later HOT 3
- Let's muse about the semantics of the new `func finish(_ hasFailed: Bool)` call of v2.0 of Queuer HOT 3
- It is support NSURLUploadTask? HOT 4
- How to run sync operations then concurrent operations in a queue? HOT 7
- Queue on Linux never gets longer than 1 HOT 7
- finish(success: Bool) does nothing to success HOT 2
- Chained operation results HOT 2
- SPM Warning HOT 2
- Serial task HOT 3
- Documentation link seems broken HOT 4
- Possible to create a unviersal queue for alamofire requests? HOT 1
- Operations are `isFinished=true` without me explicitly calling `operation.finish()` HOT 2
- Is this the expected output? HOT 1
- documentation is not available HOT 2
- Queuer on Linux Ubuntu 16.04 HOT 1
- Queuer by CocoaPod HOT 6
- Need to get the underlyingQueue. Make OperationQueue public? HOT 5
- How to bring persistence? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from queuer.