@@ -37,28 +37,39 @@ impl<Args, Output: Default> Default for OpQueue<Args, Output> {
37
37
}
38
38
39
39
impl < Args , Output > OpQueue < Args , Output > {
40
+ /// Request an operation to start.
40
41
pub ( crate ) fn request_op ( & mut self , reason : Cause , args : Args ) {
41
42
self . op_requested = Some ( ( reason, args) ) ;
42
43
}
44
+
45
+ /// If there was an operation requested, mark this queue as
46
+ /// started and return the request arguments.
43
47
pub ( crate ) fn should_start_op ( & mut self ) -> Option < ( Cause , Args ) > {
44
48
if self . op_in_progress {
45
49
return None ;
46
50
}
47
51
self . op_in_progress = self . op_requested . is_some ( ) ;
48
52
self . op_requested . take ( )
49
53
}
54
+
55
+ /// Mark an operation as completed.
50
56
pub ( crate ) fn op_completed ( & mut self , result : Output ) {
51
57
assert ! ( self . op_in_progress) ;
52
58
self . op_in_progress = false ;
53
59
self . last_op_result = result;
54
60
}
55
61
62
+ /// Get the result of the last operation.
56
63
pub ( crate ) fn last_op_result ( & self ) -> & Output {
57
64
& self . last_op_result
58
65
}
66
+
67
+ // Is there an operation that has started, but hasn't yet finished?
59
68
pub ( crate ) fn op_in_progress ( & self ) -> bool {
60
69
self . op_in_progress
61
70
}
71
+
72
+ // Has an operation been requested?
62
73
pub ( crate ) fn op_requested ( & self ) -> bool {
63
74
self . op_requested . is_some ( )
64
75
}
0 commit comments