Skip to content

Commit

Permalink
Addressed code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clark Gaebel committed Oct 27, 2014
1 parent b0d1646 commit 293969c
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/util/workqueue.rs
Expand Up @@ -71,7 +71,9 @@ struct WorkerThread<QueueData, WorkData> {
rng: XorShiftRng,
}

static SPIN_COUNT: uint = 128;
static SPIN_COUNT: u32 = 128;
static SPINS_UNTIL_BACKOFF: u32 = 100;
static BACKOFF_INCREMENT_IN_US: u32 = 5;

impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
/// The main logic. This function starts up the worker and listens for
Expand All @@ -85,10 +87,11 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
ExitMsg => return,
};

let mut back_off_sleep = 0 as u32;

// We're off!
//
// FIXME(pcwalton): Can't use labeled break or continue cross-crate due to a Rust bug.
let mut back_off_sleep = 0 as u32;
loop {
// FIXME(pcwalton): Nasty workaround for the lack of labeled break/continue
// cross-crate.
Expand All @@ -114,10 +117,13 @@ impl<QueueData: Send, WorkData: Send> WorkerThread<QueueData, WorkData> {
}
}

if (i>100) {
unsafe {usleep(back_off_sleep as u32)};
back_off_sleep = back_off_sleep + 5;
if i > SPINS_UNTIL_BACKOFF {
unsafe {
usleep(back_off_sleep as u32);
}
back_off_sleep += BACKOFF_INCREMENT_IN_US;
}

if i == SPIN_COUNT {
match self.port.try_recv() {
Ok(StopMsg) => {
Expand Down

5 comments on commit 293969c

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from pcwalton
at cgaebel@293969c

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging cgaebel/servo/rebase-lalehs-patch = 293969c into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cgaebel/servo/rebase-lalehs-patch = 293969c merged ok, testing candidate = 9e94ecf

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9e94ecf

Please sign in to comment.