Async Loading outdir and proc-macro
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
//! Bookkeeping to make sure only one long-running operation is executed.
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct OpQueue {
|
||||
op_scheduled: bool,
|
||||
pub(crate) struct OpQueue<D> {
|
||||
op_scheduled: Option<D>,
|
||||
op_in_progress: bool,
|
||||
}
|
||||
|
||||
impl OpQueue {
|
||||
pub(crate) fn request_op(&mut self) {
|
||||
self.op_scheduled = true;
|
||||
impl<D> Default for OpQueue<D> {
|
||||
fn default() -> Self {
|
||||
Self { op_scheduled: None, op_in_progress: false }
|
||||
}
|
||||
pub(crate) fn should_start_op(&mut self) -> bool {
|
||||
if !self.op_in_progress && self.op_scheduled {
|
||||
self.op_in_progress = true;
|
||||
self.op_scheduled = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
impl<D> OpQueue<D> {
|
||||
pub(crate) fn request_op(&mut self, data: D) {
|
||||
self.op_scheduled = Some(data);
|
||||
}
|
||||
pub(crate) fn should_start_op(&mut self) -> Option<D> {
|
||||
if self.op_in_progress {
|
||||
return None;
|
||||
}
|
||||
false
|
||||
self.op_in_progress = self.op_scheduled.is_some();
|
||||
self.op_scheduled.take()
|
||||
}
|
||||
pub(crate) fn op_completed(&mut self) {
|
||||
assert!(self.op_in_progress);
|
||||
|
||||
Reference in New Issue
Block a user