Giter Club home page Giter Club logo

Comments (4)

boxerab avatar boxerab commented on July 26, 2024

Thanks ansoni. Now, there are no class variables in Objective C. Perhaps you meant static; but svgXml is not static.
So, not sure what the issue is here......

from svgquartzrenderer.

ansoni avatar ansoni commented on July 26, 2024

Indeed class scope was the wrong wording. Instance scope is how I would describe it.

So we have the NSData* svgXml declaration in the header file declared as a private variable. So, when I create an instance of SVQuartzRenderer, it will have a single svgXm variable.

The svgXml pointer gets initialized at the beginning of the parse method, then the data gets parsed which might take a few millisseconds and then the pointer is free'd. If called twice from two different threads at the exact same time, I would expect one or both concurrent method calls to fail with this potential scenario:

1st call creates an NSData object and writes the address to the svgXml variable.
1st call goes on to use the variable.
2nd call creates a new NSData object and overwrites the existing svgXml pointer.
1st call potentially could potentially error here.
2nd call goes on to use the variable.
1st call releases the svgXML variable
2nd call might go bad here?
2nd call tries to release svgXML variable.

I will write some code to verify this behavior so you don't need to waste time if this is Obj-C ignorance on my part.

from svgquartzrenderer.

boxerab avatar boxerab commented on July 26, 2024

Hi Anonsi,
The parser is not designed to be thread safe. If two threads need the same parser, they must implement locking
to avoid data corruption.

from svgquartzrenderer.

boxerab avatar boxerab commented on July 26, 2024

BTW, Anonsi, private just means that derived classes do not have access to the variable. It doesn't mean that two instances of the parser share the same variable. If it is marked static, then it will be shared.

from svgquartzrenderer.

Related Issues (11)

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.