Re: usleep()
Re: usleep()
- Subject: Re: usleep()
- From: Michael Watson <email@hidden>
- Date: Sat, 15 Mar 2008 10:18:27 -0400
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@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:
@bungie.org
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
References: | |
| >usleep() (From: Cocoa <email@hidden>) |