Skip to main content

euv_core/window/control/
impl.rs

1use super::*;
2
3/// Queueing and draining methods for `WindowCommandQueue`.
4impl WindowCommandQueue {
5    /// Pushes a window command onto the queue.
6    ///
7    /// # Arguments
8    ///
9    /// - `&Self` - Mutable command queue.
10    /// - `WindowCommand` - Command to enqueue.
11    pub fn push(&mut self, command: WindowCommand) {
12        self.get_mut_commands().push(command);
13    }
14
15    /// Drains all queued commands in FIFO order.
16    ///
17    /// # Arguments
18    ///
19    /// - `&Self` - Mutable command queue.
20    ///
21    /// # Returns
22    ///
23    /// - `Vec<WindowCommand>` - Drained commands.
24    pub fn drain(&mut self) -> Vec<WindowCommand> {
25        take(self.get_mut_commands())
26    }
27
28    /// Returns true when no window commands are pending.
29    ///
30    /// # Arguments
31    ///
32    /// - `&Self` - Command queue reference.
33    ///
34    /// # Returns
35    ///
36    /// - `bool` - True when empty.
37    #[must_use]
38    pub fn is_empty(&self) -> bool {
39        self.get_commands().is_empty()
40    }
41}