memkit_gpu/
sync.rs

1//! GPU synchronization primitives.
2
3/// A GPU fence for synchronization.
4pub struct MkFence {
5    signaled: bool,
6}
7
8impl MkFence {
9    /// Create a new unsignaled fence.
10    pub fn new() -> Self {
11        Self { signaled: false }
12    }
13
14    /// Create a new signaled fence.
15    pub fn signaled() -> Self {
16        Self { signaled: true }
17    }
18
19    /// Check if the fence is signaled.
20    pub fn is_signaled(&self) -> bool {
21        self.signaled
22    }
23
24    /// Signal the fence.
25    pub fn signal(&mut self) {
26        self.signaled = true;
27    }
28
29    /// Reset the fence.
30    pub fn reset(&mut self) {
31        self.signaled = false;
32    }
33
34    /// Wait for the fence to be signaled.
35    pub fn wait(&self) {
36        // For now, just spin (real implementation would use backend)
37        while !self.signaled {
38            std::hint::spin_loop();
39        }
40    }
41}
42
43impl Default for MkFence {
44    fn default() -> Self {
45        Self::new()
46    }
47}