memkit-gpu 0.2.0-beta.1

Backend-agnostic GPU memory management for memkit
//! GPU synchronization primitives.

/// A GPU fence for synchronization.
pub struct MkFence {
    signaled: bool,
}

impl MkFence {
    /// Create a new unsignaled fence.
    pub fn new() -> Self {
        Self { signaled: false }
    }

    /// Create a new signaled fence.
    pub fn signaled() -> Self {
        Self { signaled: true }
    }

    /// Check if the fence is signaled.
    pub fn is_signaled(&self) -> bool {
        self.signaled
    }

    /// Signal the fence.
    pub fn signal(&mut self) {
        self.signaled = true;
    }

    /// Reset the fence.
    pub fn reset(&mut self) {
        self.signaled = false;
    }

    /// Wait for the fence to be signaled.
    pub fn wait(&self) {
        // For now, just spin (real implementation would use backend)
        while !self.signaled {
            std::hint::spin_loop();
        }
    }
}

impl Default for MkFence {
    fn default() -> Self {
        Self::new()
    }
}