Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Added wait_to_build time to config #391

Merged
merged 2 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ pub enum BuildPriority {
Normal,
}

// Minimum time to wait before starting a `BuildPriority::Normal` build.
const WAIT_TO_BUILD: u64 = 500;

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
enum Signal {
Build,
Expand Down Expand Up @@ -166,7 +163,12 @@ impl BuildQueue {
let (tx, rx) = channel();
self.pending.lock().unwrap().push(tx);
if priority == BuildPriority::Normal {
thread::sleep(Duration::from_millis(WAIT_TO_BUILD));
let wait_to_build = { // Release lock before we sleep
Copy link
Member

Choose a reason for hiding this comment

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

Good catch!

let config = self.config.lock().unwrap();
config.wait_to_build
};

thread::sleep(Duration::from_millis(wait_to_build as u64));
Copy link
Member

Choose a reason for hiding this comment

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

You could make the config option u64 and then you wouldn't need this cast.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I need to add a new impl for ConfigType for that.
Should the variant name be "<unsigned 64bit integer>"?

Copy link
Member

Choose a reason for hiding this comment

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

that sounds good

}

if self.running.load(Ordering::SeqCst) {
Expand Down
1 change: 1 addition & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ create_config! {
build_bin: String, String::new(), false, "cargo check --bin <name>";
cfg_test: bool, true, false, "build cfg(test) code";
unstable_features: bool, false, false, "enable unstable features";
wait_to_build: usize, 500, false, "time between receiving a change notification and starting build";
Copy link
Member

Choose a reason for hiding this comment

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

Could you add "in milliseconds" to the description please?

}

/// A rustfmt config (typically specified via rustfmt.toml)
Expand Down