internal: simplify handling of the build scripts
This commit is contained in:
@@ -1,28 +1,29 @@
|
||||
//! Bookkeeping to make sure only one long-running operation is being executed
|
||||
//! at a time.
|
||||
|
||||
pub(crate) struct OpQueue<Args, Output> {
|
||||
op_requested: Option<Args>,
|
||||
pub(crate) struct OpQueue<Output> {
|
||||
op_requested: bool,
|
||||
op_in_progress: bool,
|
||||
last_op_result: Output,
|
||||
}
|
||||
|
||||
impl<Args, Output: Default> Default for OpQueue<Args, Output> {
|
||||
impl<Output: Default> Default for OpQueue<Output> {
|
||||
fn default() -> Self {
|
||||
Self { op_requested: None, op_in_progress: false, last_op_result: Default::default() }
|
||||
Self { op_requested: false, op_in_progress: false, last_op_result: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Args, Output> OpQueue<Args, Output> {
|
||||
pub(crate) fn request_op(&mut self, data: Args) {
|
||||
self.op_requested = Some(data);
|
||||
impl<Output> OpQueue<Output> {
|
||||
pub(crate) fn request_op(&mut self) {
|
||||
self.op_requested = true;
|
||||
}
|
||||
pub(crate) fn should_start_op(&mut self) -> Option<Args> {
|
||||
pub(crate) fn should_start_op(&mut self) -> bool {
|
||||
if self.op_in_progress {
|
||||
return None;
|
||||
return false;
|
||||
}
|
||||
self.op_in_progress = self.op_requested.is_some();
|
||||
self.op_requested.take()
|
||||
self.op_in_progress = self.op_requested;
|
||||
self.op_requested = false;
|
||||
self.op_in_progress
|
||||
}
|
||||
pub(crate) fn op_completed(&mut self, result: Output) {
|
||||
assert!(self.op_in_progress);
|
||||
@@ -30,7 +31,6 @@ impl<Args, Output> OpQueue<Args, Output> {
|
||||
self.last_op_result = result;
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub(crate) fn last_op_result(&self) -> &Output {
|
||||
&self.last_op_result
|
||||
}
|
||||
@@ -38,6 +38,6 @@ impl<Args, Output> OpQueue<Args, Output> {
|
||||
self.op_in_progress
|
||||
}
|
||||
pub(crate) fn op_requested(&self) -> bool {
|
||||
self.op_requested.is_some()
|
||||
self.op_requested
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user