That depends entirely on how the singleton behaves - if it behaves correctly when called from multiple threads/queues, and from different contexts, it should be fine. If the interface needs ordering across calls you'll need to add a lock.
For example, if the interface is just -(id)getLatestThing you're probably in good shape. If it's something like -(void)setSomeState:(id)state -(id)getResults you'll need to lock, otherwise another thread could setSomeState to something else between the two calls and you'll get undefined results. Not to mention that just setting state might not be thread-safe (and since thread-safety doesn't compose, you can't count on FramesProducer's internal locks helping you anyway even if it doesn't crash). On Dec 23, 2014, at 2:20 AM, Nisar Ahmed <nisar....@gmail.com> wrote: > I am using QCRenderer to render a composition which has a custom plugin > generating video from hardware device. I am also using same hardware device > inside the host application using an static object using dispatch_once token > so that this object is never created twice. > > Can I reuse that static object inside my plugin instead of creating a new > instance? I have tried using same class inside my QCPlugin target but > QCPlugin is initialising its own instance which is of course failing because > hardware is already in use. > > +(id)sharedProducer > { > static FramesProducer *producer; > static dispatch_once_t onceToken; > dispatch_once(&onceToken, ^{ > producer = [[FramesProducer alloc] initWithDeviceIndex:1]; > NSLog(@"producer %@", producer); > }); > return producer; > } > > Thanks > Nisar > _______________________________________________ > Do not post admin requests to the list. They will be ignored. > Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com) > Help/Unsubscribe/Update your Subscription: > https://lists.apple.com/mailman/options/quartzcomposer-dev/christopher_wright%40apple.com > > This email sent to christopher_wri...@apple.com -- Christopher Wright christopher_wri...@apple.com
_______________________________________________ Do not post admin requests to the list. They will be ignored. Quartzcomposer-dev mailing list (Quartzcomposer-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com