diff options
Diffstat (limited to 'src/stable/myriad.cpp')
-rw-r--r-- | src/stable/myriad.cpp | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/src/stable/myriad.cpp b/src/stable/myriad.cpp index 03cffa9..492676e 100644 --- a/src/stable/myriad.cpp +++ b/src/stable/myriad.cpp | |||
@@ -129,6 +129,19 @@ Bu::MyriadStream Bu::Myriad::open( Bu::Myriad::StreamId iStream, | |||
129 | return Bu::MyriadStream( *this, pStream, eMode ); | 129 | return Bu::MyriadStream( *this, pStream, eMode ); |
130 | } | 130 | } |
131 | 131 | ||
132 | Bu::Myriad::StreamId Bu::Myriad::allocate() | ||
133 | { | ||
134 | Bu::MutexLocker l( mAccess ); | ||
135 | |||
136 | Stream *pStream = new Stream( *this, ++iLastUsedIndex, 0 ); | ||
137 | mhStream.lock(); | ||
138 | hStream.insert( pStream->iStream, pStream ); | ||
139 | mhStream.unlock(); | ||
140 | bStructureChanged = true; | ||
141 | |||
142 | return pStream->iStream; | ||
143 | } | ||
144 | |||
132 | void Bu::Myriad::erase( Bu::Myriad::StreamId iStream ) | 145 | void Bu::Myriad::erase( Bu::Myriad::StreamId iStream ) |
133 | { | 146 | { |
134 | // For now, let's prevent you from erasing a stream if it's open. | 147 | // For now, let's prevent you from erasing a stream if it's open. |
@@ -252,6 +265,19 @@ int32_t Bu::Myriad::getTotalUnusedBytes(int32_t iAssumeBlockSize ) const | |||
252 | return iTotal; | 265 | return iTotal; |
253 | } | 266 | } |
254 | 267 | ||
268 | Bu::Myriad::StreamIdList Bu::Myriad::getStreamList() const | ||
269 | { | ||
270 | mhStream.lock(); | ||
271 | StreamIdList lIds = hStream.getKeys(); | ||
272 | mhStream.unlock(); | ||
273 | lIds.sort(); | ||
274 | if( lIds.first() == 0 ) | ||
275 | { | ||
276 | lIds.eraseFirst(); | ||
277 | } | ||
278 | return lIds; | ||
279 | } | ||
280 | |||
255 | Bu::BitString Bu::Myriad::buildBlockUseMap() const | 281 | Bu::BitString Bu::Myriad::buildBlockUseMap() const |
256 | { | 282 | { |
257 | Bu::MutexLocker l( mAccess ); | 283 | Bu::MutexLocker l( mAccess ); |
@@ -264,10 +290,10 @@ Bu::BitString Bu::Myriad::buildBlockUseMap() const | |||
264 | return bsMap; | 290 | return bsMap; |
265 | } | 291 | } |
266 | 292 | ||
267 | Bu::Array<int32_t> Bu::Myriad::buildBlockMap() const | 293 | Bu::Myriad::StreamIdArray Bu::Myriad::buildBlockMap() const |
268 | { | 294 | { |
269 | Bu::MutexLocker l( mAccess ); | 295 | Bu::MutexLocker l( mAccess ); |
270 | Bu::Array<int32_t> bm( iBlockCount ); | 296 | StreamIdArray bm( iBlockCount ); |
271 | for( int j = 0; j < iBlockCount; j++ ) | 297 | for( int j = 0; j < iBlockCount; j++ ) |
272 | { | 298 | { |
273 | bm.append( -1 ); | 299 | bm.append( -1 ); |
@@ -768,9 +794,7 @@ int32_t Bu::Myriad::Stream::read( int32_t iStart, void *pTarget, | |||
768 | 794 | ||
769 | if( iStart+iSize >= this->iSize ) | 795 | if( iStart+iSize >= this->iSize ) |
770 | { | 796 | { |
771 | int32_t iDiff = (iStart+iSize)-this->iSize; | 797 | iSize = this->iSize-iStart; |
772 | iSize -= iDiff; | ||
773 | iStart += iDiff; | ||
774 | } | 798 | } |
775 | 799 | ||
776 | while( iSize > 0 ) | 800 | while( iSize > 0 ) |