Giter Club home page Giter Club logo

Comments (6)

peternlewis avatar peternlewis commented on August 11, 2024 1

Yes, I had a quick look and it looks similar to what I did.

from vdkqueue.

peternlewis avatar peternlewis commented on August 11, 2024

Actually NSThread retains its target, so _keepWatcherThreadRunning will never be set to NO in dealloc because dealloc will never be called while the thread is running.

However the same race condition will occur if you remove a path any other way since the removal is not synced with the thread.

from vdkqueue.

bdkjones avatar bdkjones commented on August 11, 2024

Holy hell, you’re totally right. Can’t believe I missed that. I can fix this in the next couple weeks, but if you’re willing to put together a PR I’d be happy to merge. Thanks!

On 24 Apr 2015, at 01:00, Peter N Lewis [email protected] wrote:

Actually NSThread retains its target, so _keepWatcherThreadRunning will never be set to NO in dealloc because dealloc will never be called while the thread is running.

However the same race condition will occur if you remove a path any other way since the removal is not synced with the thread.


Reply to this email directly or view it on GitHub #13 (comment).

from vdkqueue.

peternlewis avatar peternlewis commented on August 11, 2024

I'm afraid I have trouble with github and pullrequests. I am entirely vandalizing the code (there is not much left really) for my purposes, but my solution for this issue went something like this:

static ptrint_t gUniqueIndex = 1;

each entry gets a ptrint_t_uniqueIndex, initialized to gUniqueIndex++

Add another NSMutableDictionary mapping uniqueIndex to entries.

Put the uniqueIndex in the event data field.

In the thread, within the @syncronized, look up the event based on the uniqueIndex.

My code is 64-bit only, so unique index will never wrap so that is never an issue.

And the thread already references self in other places, so avoiding referencing self is pointless (just make sure to use the @synronized).

I'm sure there are many other solutions, but I generally dislike keeping unsafe unretained references to objects and prefer for this sort of thing to use a safe index that looks to see if the object is still alive.

I'm happy to email the (as I say, highly vandalised) code to you to look at if you like (peter at stairways.com.au), though I haven't actually finished and got it working yet so no real guarantees, but it can show my thinking.

from vdkqueue.

bdkjones avatar bdkjones commented on August 11, 2024

That’d be great. If you can send me a copy once you’re done with it, I’m @bdkjones on Twitter or bryan at incident 57 dot com.

On 24 Apr 2015, at 04:19, Peter N Lewis [email protected] wrote:

I'm afraid I have trouble with github and pullrequests. I am entirely vandalizing the code (there is not much left really) for my purposes, but my solution for this issue went something like this:

static ptrint_t gUniqueIndex = 1;

each entry gets a ptrint_t_uniqueIndex, initialized to gUniqueIndex++

Add another NSMutableDictionary mapping uniqueIndex to entries.

Put the uniqueIndex in the event data field.

In the thread, within the @syncronized https://github.com/syncronized, look up the event based on the uniqueIndex.

My code is 64-bit only, so unique index will never wrap so that is never an issue.

And the thread already references self in other places, so avoiding referencing self is pointless (just make sure to use the @synronized).

I'm sure there are many other solutions, but I generally dislike keeping unsafe unretained references to objects and prefer for this sort of thing to use a safe index that looks to see if the object is still alive.

I'm happy to email the (as I say, highly vandalised) code to you to look at if you like (peter at stairways.com.au), though I haven't actually finished and got it working yet so no real guarantees, but it can show my thinking.


Reply to this email directly or view it on GitHub #13 (comment).

from vdkqueue.

gobbledegook avatar gobbledegook commented on August 11, 2024

@peternlewis if you're still monitoring this, is the patch I just posted along the lines of what you were saying? I'm using it in a current project and it seems to be working ok...

from vdkqueue.

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.