Replies: 1 comment
|
I'm so glad you brought this up! Internally, the let task = queue.addOperation {
}
print("identifier:", task.hashValue)
task.cancel()Would it be possible to make use of this hashValue as a way of tying the work together? Also, is the cancelation is an optimization? Task cancellation is inherently racy, but if you need to guarantee cancellation happens I'd have to think a lot harder about how to pull it off. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I have my own implementation of your
Queuecode in my codebase which I wrote before I knew about this library. @groue told me about yours, and what I like about your code is that it has concepts like barriers which I don't have.One thing that could be useful is to expose the task ID in a queue, with the ability to explicitly assign a task ID to a queue entry, and the ability to replace a queue entry by ID.
My use case is syncing code that syncs local changes to the backend. In my code, I reuse the ID of the entity I sync as queue entry ID, and when a user makes two changes in a row, I can cancel the first backend call and replace it with the newer one.
All reactions