usleep is deprecated, please don't use it. it has been replaced with
nanosleep.


On Wed, Feb 19, 2014 at 4:21 AM, Alex Crichton <notifications@github.com>wrote:

> In src/libgreen/sched.rs:
>
> > -            sched.idle_callback.get_mut_ref().pause();
> > -        } else {
> > -            rtdebug!("not sleeping, already doing so or no_sleep set");
> > -            // We may not be sleeping, but we still need to deactivate
> > -            // the idle callback.
> > -            sched.idle_callback.get_mut_ref().pause();
> > +        unsafe {
> > +            if !sched.no_sleep && !(*sched.sleepy.get()).load(SeqCst) {
> > +                if sched.backoff_counter == EXPONENTIAL_BACKOFF_FACTOR {
> > +                    sched.backoff_counter = 0;
> > +                    rtdebug!("scheduler has no work to do, going to sleep");
> > +                    (*sched.sleepy.get()).store(true, SeqCst);
> > +                    // Since we are sleeping, deactivate the idle callback.
> > +                    sched.idle_callback.get_mut_ref().pause();
> > +                } else if !sched.event_loop.has_active_io() {
> > +                    unistd::usleep((1 << sched.backoff_counter) * 1000u as u32);
>
> Once you get into millisecond territory, I don't think usleep should be
> used, but rather the event loop itself so I/O can wake up the scheduler.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/mozilla/rust/pull/12254/files#r9858586>
> .
>