From 64106c4d3d4ddba8c7bc2af75376e6d3d3d75601 Mon Sep 17 00:00:00 2001
From:
Date: Mon, 29 Jun 2015 20:16:15 +0000
Subject: Update documentation
---
src/carboxyl/readonly.rs.html | 173 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
create mode 100644 src/carboxyl/readonly.rs.html
(limited to 'src/carboxyl/readonly.rs.html')
diff --git a/src/carboxyl/readonly.rs.html b/src/carboxyl/readonly.rs.html
new file mode 100644
index 0000000..84fce7f
--- /dev/null
+++ b/src/carboxyl/readonly.rs.html
@@ -0,0 +1,173 @@
+
+
+
+ 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+
+
+
+use std::sync::{ Arc, RwLock, RwLockReadGuard };
+use std::ops::Deref;
+
+
+pub struct ReadOnlyGuard<'a, T: 'a> {
+ guard: RwLockReadGuard<'a, T>,
+}
+
+impl<'a, T> Deref for ReadOnlyGuard<'a, T> {
+ type Target = T;
+ fn deref(&self) -> &T { &self.guard }
+}
+
+
+pub struct ReadOnly<T> {
+ ptr: Arc<RwLock<T>>,
+}
+
+impl<T> Clone for ReadOnly<T> {
+ fn clone(&self) -> ReadOnly<T> {
+ ReadOnly { ptr: self.ptr.clone() }
+ }
+}
+
+
+pub fn create<T>(ptr: Arc<RwLock<T>>) -> ReadOnly<T> { ReadOnly { ptr: ptr } }
+
+impl<T> ReadOnly<T> {
+
+
+
+
+ pub fn read(&self) -> Option<ReadOnlyGuard<T>> {
+ self.ptr.read().ok().map(|g| ReadOnlyGuard { guard: g })
+ }
+}
+
+
+