From 49d9fa3c2435b8e97ffdc42e40a880a3dad82f8a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Sat, 14 Apr 2012 17:38:13 +0000 Subject: 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. --- src/stable/myriad.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/stable/myriad.h') 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 @@ #include "bu/exceptionbase.h" #include "bu/array.h" #include "bu/hash.h" +#include "bu/mutex.h" namespace Bu { @@ -148,6 +149,13 @@ namespace Bu */ void sync(); + /** + * Read the first few bytes from the given stream and return true/false + * depending on weather or not it's a Myriad stream. This will throw + * an exception if the stream is empty, or is not random access. + */ + static bool isMyriad( Bu::Stream &sStore, uint8_t &uVer ); + /** * Read the first few bytes from the given stream and return true/false * depending on weather or not it's a Myriad stream. This will throw @@ -216,6 +224,9 @@ namespace Bu typedef Bu::Hash BlockHash; BlockHash hActiveBlocks; bool bHeaderChanged; + + Bu::Mutex mHeader; + Bu::Mutex mActiveBlocks; }; }; -- cgit v1.2.3