• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Accessing array in thread safe way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accessing array in thread safe way


  • Subject: Re: Accessing array in thread safe way
  • From: CoGe - Tamas Nagy <email@hidden>
  • Date: Fri, 09 Mar 2012 10:17:55 +0100

Thanks for the suggestion, its really appreciated! I'll do some tests - actually the GCD way seems to be the forward.

Anyway, maybe the array contains non-thread safe objects (QCRenderers) - object that should not be bounce between different threads. But with those, I think I can't use GCD, because GCD cannot guarantie operations will perform on the exact same thread - or at least in my understanding.

On Mar 9, 2012, at 9:51 AM, Quincey Morris wrote:

> On Mar 9, 2012, at 00:30 , CoGe - Tamas Nagy wrote:
>
>> Thanks Quiencey to pointing this out, however, what you suggest instead of the current implementation? What I use for this class is putting and/or update  objects into it from different threads, then access it from an other (reader) thread (via objectAtIndex: and by enumarating).
>
> It depends on how often the array gets updated and how big it is. One simple approach is to serialize all access to the array through the main thread (e.g. via 'performSelectorOnMainThread'), but you'd have to enumerate a (serially-retrieved) copy of the array each time.
>
> The most flexible solution might be to use NSOperationQueue (or GCD) to set up some kind of producer/consumer model. But it still depends on the details of what you're trying to do.
>
>






_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Accessing array in thread safe way
      • From: Roland King <email@hidden>
References: 
 >Accessing array in thread safe way (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Accessing array in thread safe way (From: Charles Srstka <email@hidden>)
 >Re: Accessing array in thread safe way (From: "Jan E. Schotsman" <email@hidden>)
 >Re: Accessing array in thread safe way (From: CoGe - Tamas Nagy <email@hidden>)
 >Re: Accessing array in thread safe way (From: Charles Srstka <email@hidden>)
 >Re: Accessing array in thread safe way (From: CoGe - Tamas Nagy <email@hidden>)
 >Re: Accessing array in thread safe way (From: Quincey Morris <email@hidden>)
 >Re: Accessing array in thread safe way (From: Charles Srstka <email@hidden>)
 >Re: Accessing array in thread safe way (From: Quincey Morris <email@hidden>)
 >Re: Accessing array in thread safe way (From: CoGe - Tamas Nagy <email@hidden>)
 >Re: Accessing array in thread safe way (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: @-directives
  • Next by Date: Re: Uncaught Exception: NSUnknownKeyException
  • Previous by thread: Re: Accessing array in thread safe way
  • Next by thread: Re: Accessing array in thread safe way
  • Index(es):
    • Date
    • Thread