aboutsummaryrefslogtreecommitdiff
path: root/src/stable/myriad.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-04-14 17:38:13 +0000
committerMike Buland <eichlan@xagasoft.com>2012-04-14 17:38:13 +0000
commit49d9fa3c2435b8e97ffdc42e40a880a3dad82f8a (patch)
tree98afeeeccd5105ea812f1b6507cbd6ef1364a91f /src/stable/myriad.h
parent91f9d6e8b371f339dbcc16541054f9cb371d0ec9 (diff)
downloadlibbu++-49d9fa3c2435b8e97ffdc42e40a880a3dad82f8a.tar.gz
libbu++-49d9fa3c2435b8e97ffdc42e40a880a3dad82f8a.tar.bz2
libbu++-49d9fa3c2435b8e97ffdc42e40a880a3dad82f8a.tar.xz
libbu++-49d9fa3c2435b8e97ffdc42e40a880a3dad82f8a.zip
The core of myriad is now thread-safe. It could use a little work on multiple
streams accessing the same blocks at the same time. Right now it's safe, but a little strange, since both streams work from seperate buffers. Maybe that's ok, but it still needs some more investigation. I want to remove the BitString stuff entirely, it turns out it's the slowest part, which, upon actually looking at the code is completely obvious. This change shouldn't change the API at all, just make adding blocks to streams much, much faster.
Diffstat (limited to 'src/stable/myriad.h')
-rw-r--r--src/stable/myriad.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/stable/myriad.h b/src/stable/myriad.h
index 3382ab5..14e8c73 100644
--- a/src/stable/myriad.h
+++ b/src/stable/myriad.h
@@ -13,6 +13,7 @@
13#include "bu/exceptionbase.h" 13#include "bu/exceptionbase.h"
14#include "bu/array.h" 14#include "bu/array.h"
15#include "bu/hash.h" 15#include "bu/hash.h"
16#include "bu/mutex.h"
16 17
17namespace Bu 18namespace Bu
18{ 19{
@@ -153,6 +154,13 @@ namespace Bu
153 * depending on weather or not it's a Myriad stream. This will throw 154 * depending on weather or not it's a Myriad stream. This will throw
154 * an exception if the stream is empty, or is not random access. 155 * an exception if the stream is empty, or is not random access.
155 */ 156 */
157 static bool isMyriad( Bu::Stream &sStore, uint8_t &uVer );
158
159 /**
160 * Read the first few bytes from the given stream and return true/false
161 * depending on weather or not it's a Myriad stream. This will throw
162 * an exception if the stream is empty, or is not random access.
163 */
156 static bool isMyriad( Bu::Stream &sStore ); 164 static bool isMyriad( Bu::Stream &sStore );
157 165
158 const Bu::BitString &getBlocksUsed() const; 166 const Bu::BitString &getBlocksUsed() const;
@@ -216,6 +224,9 @@ namespace Bu
216 typedef Bu::Hash<int, Block *> BlockHash; 224 typedef Bu::Hash<int, Block *> BlockHash;
217 BlockHash hActiveBlocks; 225 BlockHash hActiveBlocks;
218 bool bHeaderChanged; 226 bool bHeaderChanged;
227
228 Bu::Mutex mHeader;
229 Bu::Mutex mActiveBlocks;
219 }; 230 };
220}; 231};
221 232