• 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
Threads and Locking Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Threads and Locking Question


  • Subject: Threads and Locking Question
  • From: Dave <email@hidden>
  • Date: Thu, 10 May 2012 21:42:04 +0100

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Threads and Locking Question
      • From: Conrad Shultz <email@hidden>
    • Re: Threads and Locking Question
      • From: Ken Thomases <email@hidden>
References: 
 >[ANN] Online ScriptingBridge documentation archive (From: "email@hidden" <email@hidden>)

  • Prev by Date: Re: __bridge_transfer on a method return value
  • Next by Date: Re: Threads and Locking Question
  • Previous by thread: [ANN] Online ScriptingBridge documentation archive
  • Next by thread: Re: Threads and Locking Question
  • Index(es):
    • Date
    • Thread