Re: Threads and Locking Question
Re: Threads and Locking Question
- Subject: Re: Threads and Locking Question
- From: Dave <email@hidden>
- Date: Thu, 10 May 2012 21:54:05 +0100
Should have added, this is for iOS and doesn't have to run on Mac.
Hi,
We are using a third party library that performs tasks
asynchronously. This is ok most of the time, but on some occasions
I'd like to be able to wait (not on the main thread) until an
operation completes,
The flow basically goes like this:
[theLibraryObject doOperation:myOperation withCompletionBlock:^(void)
(ResponseObject* theResponseObject)
{
//Completion code
}];
(The Block syntax is wrong I know, but I don't have the source code
in front of me.
The "doOperation: withCompletionBlock:" method just queues the
operation and returns. When the operation has finished, it calls the
completion block.
I'd like to be able to be able to wait in the method that calls
doOperation: withCompletionBlock until the completion block is
called, something like this:
-(void) doAtomicOperation
{
[self.mLibraryObject doOperation:myOperation withCompletionBlock:^
(void)(ResponseObject* theResponseObject)
{
//**
//** Signal thread that started the operation
//**
SIGNAL
}];
//**
//** Wait for Signal before continuing
//**
WAIT_FOR_SIGNAL
}
Is there a way of doing this and if so I'd be really grateful if
someone could show me the code. I've tried using NSLock and
NSConditionalLock etc. but can't get it to work!
Thanks a lot
All the Best
Dave
_______________________________________________
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:
40looktowindward.com
This email sent to email@hidden
_______________________________________________
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