Code Monkey home page Code Monkey logo

swift-essentials's People

Contributors

depinette avatar marcsteven avatar radianttap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swift-essentials's Issues

AsyncOperation does not update .progress of OperationQueue when finished

I have just implemented your AsyncOperation in a project and it worked like a charm - until I started to use the new .progress property of OperationQueue (introduced with iOS 13).

I found out the hard way that you need to increase the .totalUnitCount of OperationQueue manually (https://stackoverflow.com/questions/60741067/progress-property-of-operationqueue-not-working-in-ios-13) when adding operations to the queue. But with this progress reporting started to work well - except for subclasses of AsyncOperation.

The .finished() method does get called on all subclasses of AsyncOperation, but somehow the .progress of the OperationQueue does not get the information about the finished task. The .operationCount of the queue decreases and the operations are removed from the [operations]. So in general AsyncOperation works. But the info about a finished operation is not signaled to the queue in a way that it can reflect this in its .progress property.

I am a bit at a loss here myself as I have no idea how iOS monitors this, so I really don't expect a quick fix. But I thought I'd let you know about this.

Thanks for your work!

AsyncOperation must be thread-safe

I read your article about AsyncOperation.

I believe your implementation isn't 100 % correct because the state property โ€” and by extension the isExecuting, isReady, and isFinished properties โ€” aren't thread-safe.

The documentation for Operation states:

When you subclass NSOperation, you must make sure that any overridden methods remain safe to call from multiple threads.

This isn't just a theoretical concern. I used to have a very similar implementation at first and when I ran it the thread sanitizer diagnosed tons of data races. You should protect all accesses to the state property behind a mutex, dispatch queue, or similar.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.