Skip navigation.
 
mlRe: usleep()
FROM : Michael Watson
DATE : Sat Mar 15 15:18:27 2008

Yes. Code in a method executes on a thread in order from top to bottom 
(taking into account flow control from while/do/etc). The usleep() 
function pauses the thread until the specified duration of time 
passes, at which point the next line of code is executed.

And remember that the thread sleep duration is only approximate. You 
aren't guaranteed exactly any number of microseconds due to processor 
timing delays. Don't rely on the specified duration being 100% accurate.


--
m-s


On 15 Mar, 2008, at 09:56, Cocoa wrote:

> these code is from ScriptBridgeConcept.pdf. Does anyone know what 
> the red code below mean, specifically rampVolume += orignalVolume/
> 16)  i search usleep() in Xcode documentation, it explain that 
> suspend thread execution for an interval measured in microseconds. 
> Does it just mean it will stop the the code for how many microseconds?
>
>
>
> - (IBAction)play:(id)sender {
> iTunesApplication *iTunes = [SBApplication
> applicationWithBundleIdentifier:@"com.apple.iTunes"];
> if ( [iTunes isRunning] ) {
> int rampVolume, originalVolume;
> originalVolume = [iTunes soundVolume];
> [iTunes setSoundVolume:0];
> [iTunes playOnce:NO];
> for (rampVolume = 0; rampVolume < originalVolume; rampVolume +=
> originalVolume / 16) {
> [iTunes setSoundVolume: rampVolume];
> /* pause 1/10th of a second (100,000 microseconds) between
> adjustments. */
> usleep(100000);
> }
> [iTunes setSoundVolume:originalVolume];
> }
> }_______________________________________________
>
> Cocoa-dev mailing list (<email_removed>)
>
> 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:
> http://lists.apple.com/mailman/options/cocoa-dev/mikey-san
> %40bungie.org
>
> This email sent to <email_removed>

Related mailsAuthorDate
mlusleep() Cocoa Mar 15, 14:56
mlRe: usleep() Michael Watson Mar 15, 15:18