File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 33
44pub ( crate ) type Cause = String ;
55
6+ /// A single-item queue that allows callers to request an operation to
7+ /// be performed later.
8+ ///
9+ /// ```
10+ /// let queue = OpQueue::default();
11+ ///
12+ /// // Request work to be done.
13+ /// queue.request_op("user pushed a button", ());
14+ ///
15+ /// // In a later iteration of the server loop, we start the work.
16+ /// if let Some((_cause, ())) = queue.should_start_op() {
17+ /// dbg!("Some slow operation here");
18+ /// }
19+ ///
20+ /// // In an even later iteration of the server loop, we can see that the work
21+ /// // was completed.
22+ /// if !queue.op_in_progress() {
23+ /// dbg!("Work has been done!");
24+ /// }
25+ /// ```
626#[ derive( Debug ) ]
727pub ( crate ) struct OpQueue < Args = ( ) , Output = ( ) > {
828 op_requested : Option < ( Cause , Args ) > ,
You can’t perform that action at this time.
0 commit comments