From 179c3d6dae9b8be39a18f8a4d3688c028a039b76 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Fri, 13 Nov 2015 12:05:14 +0100 Subject: [PATCH] Add some dummy code --- src/buffer.rs | 26 ++++++++++++++++++++++++++ src/command_buffer.rs | 5 +++-- src/lock.rs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 src/lock.rs diff --git a/src/buffer.rs b/src/buffer.rs index e69de29b..a6b74e70 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -0,0 +1,26 @@ +use lock; + +unsafe trait BufferLock { + unsafe fn get_id(&self) -> u64; +} + +impl BufferLock for T where T: lock::Lock { + +} + +pub struct Buffer { + id: , +} + +unsafe impl BufferLock for Buffer { + #[inline] + unsafe fn get_id(&self) -> u64 { + self.id + } +} + +impl Drop for Buffer { + fn drop(&mut self) { + error::check_result(unsafe { ffi::grDestroyBuffer(self.id) }).unwrap(); + } +} diff --git a/src/command_buffer.rs b/src/command_buffer.rs index 89396e2f..59a7cf7f 100644 --- a/src/command_buffer.rs +++ b/src/command_buffer.rs @@ -1,3 +1,4 @@ +use buffer::BufferLock; /// Represents a prototype of a command buffer. /// @@ -24,7 +25,7 @@ pub struct CommandBufferBuilder { device: Arc, cmd: Option, memory_refs: Vec, - buffers: Vec>, + buffers: Vec>, images: Vec>, pipelines: Vec>, } @@ -85,7 +86,7 @@ pub struct CommandBuffer { device: Arc, cmd: ffi::GR_CMD_BUFFER, memory_refs: Vec, - buffers: Vec>, + buffers: Vec>, images: Vec>, pipelines: Vec>, } diff --git a/src/lock.rs b/src/lock.rs new file mode 100644 index 00000000..3d939d2b --- /dev/null +++ b/src/lock.rs @@ -0,0 +1,32 @@ +use std::sync; + +use Fence; + +/// Defines a strategy for read-write access and relation with fences. +pub trait Lock { + fn shared_access(&self); + fn exclusive_access(&self); + + fn shared_access_until(&self, Fence); + fn exclusive_access_until(&self, Fence); +} + +pub struct Mutex { + inner: sync::Mutex, + fence: Option, +} + +impl Mutex { + pub fn lock(&self) -> Result, MutexlockError> { + self.fence.wait(); + let inner = try!(self.inner.lock()); + } +} + +impl Lock for Mutex { + +} + +pub struct MutexLock<'a, T> { + inner: sync::LockGuard<'a, T>, +}