diff options
Diffstat (limited to '')
-rw-r--r-- | src/stable/myriad.cpp | 71 | ||||
-rw-r--r-- | src/stable/myriadstream.cpp | 5 |
2 files changed, 76 insertions, 0 deletions
diff --git a/src/stable/myriad.cpp b/src/stable/myriad.cpp index 4d7595a..86f651e 100644 --- a/src/stable/myriad.cpp +++ b/src/stable/myriad.cpp | |||
@@ -18,6 +18,8 @@ using Bu::Fmt; | |||
18 | 18 | ||
19 | #define Myriad_MAGIC_CODE ((unsigned char *)"\x0a\xd3\xfa\x84") | 19 | #define Myriad_MAGIC_CODE ((unsigned char *)"\x0a\xd3\xfa\x84") |
20 | 20 | ||
21 | #define TRACE( x ) Bu::println("%1:%2: %3: %4 - %5").arg(__FILE__).arg( __LINE__ ).arg(__PRETTY_FUNCTION__).arg(sStore.getLocation()).arg(x) | ||
22 | |||
21 | namespace Bu | 23 | namespace Bu |
22 | { | 24 | { |
23 | subExceptionDef( MyriadException ) | 25 | subExceptionDef( MyriadException ) |
@@ -53,11 +55,13 @@ Bu::Myriad::Myriad( Bu::Stream &sStore, int iBlockSize, int iPreallocate ) : | |||
53 | Bu::Myriad::~Myriad() | 55 | Bu::Myriad::~Myriad() |
54 | { | 56 | { |
55 | mActiveBlocks.lock(); | 57 | mActiveBlocks.lock(); |
58 | TRACE("mActiveBlocks locked."); | ||
56 | if( !hActiveBlocks.isEmpty() ) | 59 | if( !hActiveBlocks.isEmpty() ) |
57 | { | 60 | { |
58 | sio << "Bu::Myriad::~Myriad(): Error: There are " | 61 | sio << "Bu::Myriad::~Myriad(): Error: There are " |
59 | << hActiveBlocks.getSize() << " unsynced blocks!" << sio.nl; | 62 | << hActiveBlocks.getSize() << " unsynced blocks!" << sio.nl; |
60 | } | 63 | } |
64 | TRACE("mActiveBlocks unlocking..."); | ||
61 | mActiveBlocks.unlock(); | 65 | mActiveBlocks.unlock(); |
62 | sync(); | 66 | sync(); |
63 | 67 | ||
@@ -72,6 +76,7 @@ void Bu::Myriad::sync() | |||
72 | updateHeader(); | 76 | updateHeader(); |
73 | 77 | ||
74 | mActiveBlocks.lock(); | 78 | mActiveBlocks.lock(); |
79 | TRACE("mActiveBlocks locked."); | ||
75 | for( BlockHash::iterator i = hActiveBlocks.begin(); i; i++ ) | 80 | for( BlockHash::iterator i = hActiveBlocks.begin(); i; i++ ) |
76 | { | 81 | { |
77 | if( (*i)->bChanged ) | 82 | if( (*i)->bChanged ) |
@@ -79,12 +84,14 @@ void Bu::Myriad::sync() | |||
79 | syncBlock( *i ); | 84 | syncBlock( *i ); |
80 | } | 85 | } |
81 | } | 86 | } |
87 | TRACE("mActiveBlocks unlocked..."); | ||
82 | mActiveBlocks.unlock(); | 88 | mActiveBlocks.unlock(); |
83 | } | 89 | } |
84 | 90 | ||
85 | void Bu::Myriad::initialize() | 91 | void Bu::Myriad::initialize() |
86 | { | 92 | { |
87 | MutexLocker mLock( mHeader ); | 93 | MutexLocker mLock( mHeader ); |
94 | TRACE("mHeader locked."); | ||
88 | lFreeBlocks.clear(); | 95 | lFreeBlocks.clear(); |
89 | sStore.setPosEnd( 0 ); | 96 | sStore.setPosEnd( 0 ); |
90 | Bu::size iSize = sStore.tell(); | 97 | Bu::size iSize = sStore.tell(); |
@@ -92,20 +99,30 @@ void Bu::Myriad::initialize() | |||
92 | 99 | ||
93 | unsigned char buf[4]; | 100 | unsigned char buf[4]; |
94 | if( sStore.read( buf, 4 ) < 4 ) | 101 | if( sStore.read( buf, 4 ) < 4 ) |
102 | { | ||
103 | TRACE("mHeader unlocked..."); | ||
95 | throw MyriadException( MyriadException::emptyStream, | 104 | throw MyriadException( MyriadException::emptyStream, |
96 | "Input stream appears to be empty."); | 105 | "Input stream appears to be empty."); |
106 | } | ||
97 | if( memcmp( buf, Myriad_MAGIC_CODE, 4 ) ) | 107 | if( memcmp( buf, Myriad_MAGIC_CODE, 4 ) ) |
98 | { | 108 | { |
109 | TRACE("mHeader unlocked..."); | ||
99 | throw MyriadException( MyriadException::invalidFormat, | 110 | throw MyriadException( MyriadException::invalidFormat, |
100 | "Stream does not appear to be a valid Myriad format."); | 111 | "Stream does not appear to be a valid Myriad format."); |
101 | } | 112 | } |
102 | sStore.read( buf, 2 ); | 113 | sStore.read( buf, 2 ); |
103 | if( buf[0] != 1 ) | 114 | if( buf[0] != 1 ) |
115 | { | ||
116 | TRACE("mHeader unlocked..."); | ||
104 | throw MyriadException( MyriadException::badVersion, | 117 | throw MyriadException( MyriadException::badVersion, |
105 | "We can only handle version 1 for now."); | 118 | "We can only handle version 1 for now."); |
119 | } | ||
106 | if( buf[1] != 32 ) | 120 | if( buf[1] != 32 ) |
121 | { | ||
122 | TRACE("mHeader unlocked..."); | ||
107 | throw MyriadException( MyriadException::invalidWordSize, | 123 | throw MyriadException( MyriadException::invalidWordSize, |
108 | "We can only handle 32-bit words at the moment."); | 124 | "We can only handle 32-bit words at the moment."); |
125 | } | ||
109 | sStore.read( &iBlockSize, 4 ); | 126 | sStore.read( &iBlockSize, 4 ); |
110 | int iStreams; | 127 | int iStreams; |
111 | sStore.read( &iStreams, 4 ); | 128 | sStore.read( &iStreams, 4 ); |
@@ -188,11 +205,13 @@ void Bu::Myriad::initialize() | |||
188 | } | 205 | } |
189 | } | 206 | } |
190 | // sio << "Myriad: Blocks used: " << bsBlockUsed.toString() << sio.nl; | 207 | // sio << "Myriad: Blocks used: " << bsBlockUsed.toString() << sio.nl; |
208 | TRACE("mHeader unlocked..."); | ||
191 | } | 209 | } |
192 | 210 | ||
193 | void Bu::Myriad::initialize( int iBlockSize, int iPreAllocate ) | 211 | void Bu::Myriad::initialize( int iBlockSize, int iPreAllocate ) |
194 | { | 212 | { |
195 | MutexLocker mLock( mHeader ); | 213 | MutexLocker mLock( mHeader ); |
214 | TRACE("mHeader locked."); | ||
196 | lFreeBlocks.clear(); | 215 | lFreeBlocks.clear(); |
197 | 216 | ||
198 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 217 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
@@ -286,16 +305,24 @@ void Bu::Myriad::initialize( int iBlockSize, int iPreAllocate ) | |||
286 | 305 | ||
287 | bHeaderChanged = true; | 306 | bHeaderChanged = true; |
288 | //hStreams.insert( 0, BlockArray( 0 ) ); | 307 | //hStreams.insert( 0, BlockArray( 0 ) ); |
308 | TRACE("mHeader unlocked..."); | ||
289 | } | 309 | } |
290 | 310 | ||
291 | void Bu::Myriad::updateHeader() | 311 | void Bu::Myriad::updateHeader() |
292 | { | 312 | { |
293 | MutexLocker mLock( mHeader ); | 313 | MutexLocker mLock( mHeader ); |
314 | TRACE("mHeader locked."); | ||
294 | 315 | ||
295 | if( bHeaderChanged == false ) | 316 | if( bHeaderChanged == false ) |
317 | { | ||
318 | TRACE("mHeader unlocked..."); | ||
296 | return; | 319 | return; |
320 | } | ||
297 | if( !sStore.canWrite() ) | 321 | if( !sStore.canWrite() ) |
322 | { | ||
323 | TRACE("mHeader unlocked..."); | ||
298 | return; | 324 | return; |
325 | } | ||
299 | 326 | ||
300 | char cBuf; | 327 | char cBuf; |
301 | int iBuf; | 328 | int iBuf; |
@@ -363,11 +390,13 @@ void Bu::Myriad::updateHeader() | |||
363 | } | 390 | } |
364 | 391 | ||
365 | bHeaderChanged = false; | 392 | bHeaderChanged = false; |
393 | TRACE("mHeader unlocked..."); | ||
366 | } | 394 | } |
367 | 395 | ||
368 | int Bu::Myriad::createStream( int iPreAllocate ) | 396 | int Bu::Myriad::createStream( int iPreAllocate ) |
369 | { | 397 | { |
370 | MutexLocker mLock( mHeader ); | 398 | MutexLocker mLock( mHeader ); |
399 | TRACE("mHeader locked."); | ||
371 | 400 | ||
372 | Stream *pStr = new Stream(); | 401 | Stream *pStr = new Stream(); |
373 | pStr->iId = aStreams.last()->iId+1; | 402 | pStr->iId = aStreams.last()->iId+1; |
@@ -387,16 +416,19 @@ int Bu::Myriad::createStream( int iPreAllocate ) | |||
387 | 416 | ||
388 | bHeaderChanged = true; | 417 | bHeaderChanged = true; |
389 | 418 | ||
419 | TRACE("mHeader unlocked..."); | ||
390 | return pStr->iId; | 420 | return pStr->iId; |
391 | } | 421 | } |
392 | 422 | ||
393 | int Bu::Myriad::createStreamWithId( int iId, int iPreAllocate ) | 423 | int Bu::Myriad::createStreamWithId( int iId, int iPreAllocate ) |
394 | { | 424 | { |
395 | MutexLocker mLock( mHeader ); | 425 | MutexLocker mLock( mHeader ); |
426 | TRACE("mHeader locked."); | ||
396 | 427 | ||
397 | try | 428 | try |
398 | { | 429 | { |
399 | findStream( iId ); | 430 | findStream( iId ); |
431 | TRACE("mHeader unlocked..."); | ||
400 | throw MyriadException( MyriadException::streamExists, | 432 | throw MyriadException( MyriadException::streamExists, |
401 | "There is already a stream with the given id."); | 433 | "There is already a stream with the given id."); |
402 | } | 434 | } |
@@ -434,8 +466,10 @@ int Bu::Myriad::createStreamWithId( int iId, int iPreAllocate ) | |||
434 | 466 | ||
435 | bHeaderChanged = true; | 467 | bHeaderChanged = true; |
436 | 468 | ||
469 | TRACE("mHeader unlocked..."); | ||
437 | return pStr->iId; | 470 | return pStr->iId; |
438 | } | 471 | } |
472 | TRACE("mHeader unlocked..."); | ||
439 | } | 473 | } |
440 | 474 | ||
441 | int Bu::Myriad::findEmptyBlock() | 475 | int Bu::Myriad::findEmptyBlock() |
@@ -456,13 +490,20 @@ int Bu::Myriad::findEmptyBlock() | |||
456 | void Bu::Myriad::deleteStream( int iId ) | 490 | void Bu::Myriad::deleteStream( int iId ) |
457 | { | 491 | { |
458 | MutexLocker mLock( mHeader ); | 492 | MutexLocker mLock( mHeader ); |
493 | TRACE("mHeader locked."); | ||
459 | 494 | ||
460 | if( iId < 0 ) | 495 | if( iId < 0 ) |
496 | { | ||
497 | TRACE("mHeader unlocked..."); | ||
461 | throw MyriadException( MyriadException::invalidStreamId, | 498 | throw MyriadException( MyriadException::invalidStreamId, |
462 | "Invalid stream id."); | 499 | "Invalid stream id."); |
500 | } | ||
463 | if( iId == 0 ) | 501 | if( iId == 0 ) |
502 | { | ||
503 | TRACE("mHeader unlocked..."); | ||
464 | throw MyriadException( MyriadException::protectedStream, | 504 | throw MyriadException( MyriadException::protectedStream, |
465 | "You cannot delete stream zero, it is protected."); | 505 | "You cannot delete stream zero, it is protected."); |
506 | } | ||
466 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 507 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
467 | { | 508 | { |
468 | if( (*i)->iId == iId ) | 509 | if( (*i)->iId == iId ) |
@@ -477,14 +518,17 @@ void Bu::Myriad::deleteStream( int iId ) | |||
477 | aStreams.erase( i ); | 518 | aStreams.erase( i ); |
478 | bHeaderChanged = true; | 519 | bHeaderChanged = true; |
479 | delete pStream; | 520 | delete pStream; |
521 | TRACE("mHeader unlocked..."); | ||
480 | return; | 522 | return; |
481 | } | 523 | } |
482 | } | 524 | } |
525 | TRACE("mHeader unlocked..."); | ||
483 | } | 526 | } |
484 | 527 | ||
485 | Bu::Array<int> Bu::Myriad::getStreamIds() | 528 | Bu::Array<int> Bu::Myriad::getStreamIds() |
486 | { | 529 | { |
487 | MutexLocker mLock( mHeader ); | 530 | MutexLocker mLock( mHeader ); |
531 | TRACE("mHeader locked."); | ||
488 | 532 | ||
489 | Bu::Array<int> aRet( aStreams.getSize() ); | 533 | Bu::Array<int> aRet( aStreams.getSize() ); |
490 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 534 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
@@ -492,26 +536,32 @@ Bu::Array<int> Bu::Myriad::getStreamIds() | |||
492 | aRet.append( (*i)->iId ); | 536 | aRet.append( (*i)->iId ); |
493 | } | 537 | } |
494 | 538 | ||
539 | TRACE("mHeader unlocked..."); | ||
495 | return aRet; | 540 | return aRet; |
496 | } | 541 | } |
497 | 542 | ||
498 | int Bu::Myriad::getStreamSize( int iId ) | 543 | int Bu::Myriad::getStreamSize( int iId ) |
499 | { | 544 | { |
500 | MutexLocker mLock( mHeader ); | 545 | MutexLocker mLock( mHeader ); |
546 | TRACE("mHeader locked."); | ||
501 | 547 | ||
548 | TRACE("mHeader unlocked..."); | ||
502 | return findStream( iId )->iSize; | 549 | return findStream( iId )->iSize; |
503 | } | 550 | } |
504 | 551 | ||
505 | bool Bu::Myriad::hasStream( int iId ) | 552 | bool Bu::Myriad::hasStream( int iId ) |
506 | { | 553 | { |
507 | MutexLocker mLock( mHeader ); | 554 | MutexLocker mLock( mHeader ); |
555 | TRACE("mHeader locked."); | ||
508 | 556 | ||
509 | try | 557 | try |
510 | { | 558 | { |
511 | findStream( iId ); | 559 | findStream( iId ); |
560 | TRACE("mHeader unlocked..."); | ||
512 | return true; | 561 | return true; |
513 | }catch(...) | 562 | }catch(...) |
514 | { | 563 | { |
564 | TRACE("mHeader unlocked..."); | ||
515 | return false; | 565 | return false; |
516 | } | 566 | } |
517 | } | 567 | } |
@@ -519,7 +569,9 @@ bool Bu::Myriad::hasStream( int iId ) | |||
519 | Bu::MyriadStream Bu::Myriad::openStream( int iId ) | 569 | Bu::MyriadStream Bu::Myriad::openStream( int iId ) |
520 | { | 570 | { |
521 | MutexLocker mLock( mHeader ); | 571 | MutexLocker mLock( mHeader ); |
572 | TRACE("mHeader locked."); | ||
522 | 573 | ||
574 | TRACE("mHeader unlocked..."); | ||
523 | //sio << "Myriad: Request to open stream: " << iId << sio.nl; | 575 | //sio << "Myriad: Request to open stream: " << iId << sio.nl; |
524 | return MyriadStream( *this, findStream( iId ) ); | 576 | return MyriadStream( *this, findStream( iId ) ); |
525 | } | 577 | } |
@@ -527,7 +579,9 @@ Bu::MyriadStream Bu::Myriad::openStream( int iId ) | |||
527 | int Bu::Myriad::getNumStreams() | 579 | int Bu::Myriad::getNumStreams() |
528 | { | 580 | { |
529 | MutexLocker mLock( mHeader ); | 581 | MutexLocker mLock( mHeader ); |
582 | TRACE("mHeader locked."); | ||
530 | 583 | ||
584 | TRACE("mHeader unlocked..."); | ||
531 | return aStreams.getSize(); | 585 | return aStreams.getSize(); |
532 | } | 586 | } |
533 | 587 | ||
@@ -549,36 +603,42 @@ int Bu::Myriad::getNumUsedBlocks() | |||
549 | Bu::size Bu::Myriad::getTotalUsedBytes() | 603 | Bu::size Bu::Myriad::getTotalUsedBytes() |
550 | { | 604 | { |
551 | MutexLocker mLock( mHeader ); | 605 | MutexLocker mLock( mHeader ); |
606 | TRACE("mHeader locked."); | ||
552 | 607 | ||
553 | Bu::size iTotalSize = 0; | 608 | Bu::size iTotalSize = 0; |
554 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 609 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
555 | { | 610 | { |
556 | iTotalSize += (*i)->iSize; | 611 | iTotalSize += (*i)->iSize; |
557 | } | 612 | } |
613 | TRACE("mHeader unlocked..."); | ||
558 | return iTotalSize; | 614 | return iTotalSize; |
559 | } | 615 | } |
560 | 616 | ||
561 | Bu::size Bu::Myriad::getTotalUnusedBytes() | 617 | Bu::size Bu::Myriad::getTotalUnusedBytes() |
562 | { | 618 | { |
563 | MutexLocker mLock( mHeader ); | 619 | MutexLocker mLock( mHeader ); |
620 | TRACE("mHeader locked."); | ||
564 | 621 | ||
565 | Bu::size iTotalSize = (iBlocks-iUsed)*iBlockSize; | 622 | Bu::size iTotalSize = (iBlocks-iUsed)*iBlockSize; |
566 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 623 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
567 | { | 624 | { |
568 | iTotalSize += iBlockSize - ((Bu::size)(*i)->iSize%iBlockSize); | 625 | iTotalSize += iBlockSize - ((Bu::size)(*i)->iSize%iBlockSize); |
569 | } | 626 | } |
627 | TRACE("mHeader unlocked..."); | ||
570 | return iTotalSize; | 628 | return iTotalSize; |
571 | } | 629 | } |
572 | 630 | ||
573 | Bu::size Bu::Myriad::getTotalUnusedBytes( int iFakeBlockSize ) | 631 | Bu::size Bu::Myriad::getTotalUnusedBytes( int iFakeBlockSize ) |
574 | { | 632 | { |
575 | MutexLocker mLock( mHeader ); | 633 | MutexLocker mLock( mHeader ); |
634 | TRACE("mHeader locked."); | ||
576 | 635 | ||
577 | Bu::size iTotalSize = (iBlocks-iUsed)*iFakeBlockSize; | 636 | Bu::size iTotalSize = (iBlocks-iUsed)*iFakeBlockSize; |
578 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) | 637 | for( StreamArray::iterator i = aStreams.begin(); i; i++ ) |
579 | { | 638 | { |
580 | iTotalSize += iFakeBlockSize - ((*i)->iSize%iFakeBlockSize); | 639 | iTotalSize += iFakeBlockSize - ((*i)->iSize%iFakeBlockSize); |
581 | } | 640 | } |
641 | TRACE("mHeader unlocked..."); | ||
582 | return iTotalSize; | 642 | return iTotalSize; |
583 | } | 643 | } |
584 | 644 | ||
@@ -608,7 +668,9 @@ Bu::Myriad::Block *Bu::Myriad::getBlock( int iBlock ) | |||
608 | pBlock->iBlockIndex = iBlock; | 668 | pBlock->iBlockIndex = iBlock; |
609 | 669 | ||
610 | mActiveBlocks.lock(); | 670 | mActiveBlocks.lock(); |
671 | TRACE("mHeader locked."); | ||
611 | hActiveBlocks.insert( iBlock, pBlock ); | 672 | hActiveBlocks.insert( iBlock, pBlock ); |
673 | TRACE("mHeader unlocked..."); | ||
612 | mActiveBlocks.unlock(); | 674 | mActiveBlocks.unlock(); |
613 | 675 | ||
614 | return pBlock; | 676 | return pBlock; |
@@ -621,7 +683,9 @@ void Bu::Myriad::releaseBlock( Bu::Myriad::Block *pBlock ) | |||
621 | // sio << "Myriad: Releasing block " << pBlock->iBlockIndex << sio.nl; | 683 | // sio << "Myriad: Releasing block " << pBlock->iBlockIndex << sio.nl; |
622 | syncBlock( pBlock ); | 684 | syncBlock( pBlock ); |
623 | mActiveBlocks.lock(); | 685 | mActiveBlocks.lock(); |
686 | TRACE("mHeader locked."); | ||
624 | hActiveBlocks.erase( pBlock->iBlockIndex ); | 687 | hActiveBlocks.erase( pBlock->iBlockIndex ); |
688 | TRACE("mHeader unlocked..."); | ||
625 | mActiveBlocks.unlock(); | 689 | mActiveBlocks.unlock(); |
626 | 690 | ||
627 | delete[] pBlock->pData; | 691 | delete[] pBlock->pData; |
@@ -642,26 +706,31 @@ void Bu::Myriad::syncBlock( Block *pBlock ) | |||
642 | int Bu::Myriad::streamAddBlock( Stream *pStream ) | 706 | int Bu::Myriad::streamAddBlock( Stream *pStream ) |
643 | { | 707 | { |
644 | MutexLocker mLock( mHeader ); | 708 | MutexLocker mLock( mHeader ); |
709 | TRACE("mHeader locked."); | ||
645 | 710 | ||
646 | int iBlock = findEmptyBlock(); | 711 | int iBlock = findEmptyBlock(); |
647 | pStream->aBlocks.append( iBlock ); | 712 | pStream->aBlocks.append( iBlock ); |
648 | // bsBlockUsed.setBit( iBlock ); | 713 | // bsBlockUsed.setBit( iBlock ); |
649 | // bHeaderChanged = true; | 714 | // bHeaderChanged = true; |
650 | iUsed++; | 715 | iUsed++; |
716 | TRACE("mHeader unlocked..."); | ||
651 | return iBlock; | 717 | return iBlock; |
652 | } | 718 | } |
653 | 719 | ||
654 | void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) | 720 | void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) |
655 | { | 721 | { |
656 | MutexLocker mLock( mHeader ); | 722 | MutexLocker mLock( mHeader ); |
723 | TRACE("mHeader locked."); | ||
657 | 724 | ||
658 | if( pStream->iSize == iSize ) | 725 | if( pStream->iSize == iSize ) |
659 | { | 726 | { |
727 | TRACE("mHeader unlocked..."); | ||
660 | return; | 728 | return; |
661 | } | 729 | } |
662 | else if( pStream->iSize > iSize ) | 730 | else if( pStream->iSize > iSize ) |
663 | { | 731 | { |
664 | // Shrink | 732 | // Shrink |
733 | TRACE(Bu::String("Shrink stream %1 from %2 to %3").arg(pStream->iId).arg(pStream->iSize).arg(iSize).end() ); | ||
665 | for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize; | 734 | for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize; |
666 | iNewSize-iBlockSize > iSize; iNewSize -= iBlockSize ) | 735 | iNewSize-iBlockSize > iSize; iNewSize -= iBlockSize ) |
667 | { | 736 | { |
@@ -679,6 +748,7 @@ void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) | |||
679 | else | 748 | else |
680 | { | 749 | { |
681 | // Grow | 750 | // Grow |
751 | TRACE(Bu::String("Grow stream %1 from %2 to %3").arg(pStream->iId).arg(pStream->iSize).arg(iSize).end() ); | ||
682 | for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize; | 752 | for( int iNewSize = pStream->aBlocks.getSize()*iBlockSize; |
683 | iNewSize < iSize; iNewSize += iBlockSize ) | 753 | iNewSize < iSize; iNewSize += iBlockSize ) |
684 | { | 754 | { |
@@ -692,6 +762,7 @@ void Bu::Myriad::setStreamSize( Stream *pStream, long iSize ) | |||
692 | pStream->iSize = iSize; | 762 | pStream->iSize = iSize; |
693 | bHeaderChanged = true; | 763 | bHeaderChanged = true; |
694 | } | 764 | } |
765 | TRACE("mHeader unlocked..."); | ||
695 | } | 766 | } |
696 | 767 | ||
697 | void Bu::Myriad::headerChanged() | 768 | void Bu::Myriad::headerChanged() |
diff --git a/src/stable/myriadstream.cpp b/src/stable/myriadstream.cpp index b2ed75e..50c6924 100644 --- a/src/stable/myriadstream.cpp +++ b/src/stable/myriadstream.cpp | |||
@@ -17,6 +17,9 @@ | |||
17 | using Bu::sio; | 17 | using Bu::sio; |
18 | using Bu::Fmt; | 18 | using Bu::Fmt; |
19 | #endif | 19 | #endif |
20 | #include "bu/sio.h" | ||
21 | |||
22 | #define TRACE( x ) Bu::println("%1:%2: %3: %4 - %5").arg(__FILE__).arg( __LINE__ ).arg(__PRETTY_FUNCTION__).arg(rMyriad.sStore.getLocation()).arg(x) | ||
20 | 23 | ||
21 | Bu::MyriadStream::MyriadStream( Bu::Myriad &rMyriad, | 24 | Bu::MyriadStream::MyriadStream( Bu::Myriad &rMyriad, |
22 | Bu::Myriad::Stream *pStream ) : | 25 | Bu::Myriad::Stream *pStream ) : |
@@ -205,7 +208,9 @@ Bu::size Bu::MyriadStream::write( const void *pBuf, Bu::size nBytes ) | |||
205 | iAmnt | 208 | iAmnt |
206 | ); | 209 | ); |
207 | iPos += iAmnt; | 210 | iPos += iAmnt; |
211 | TRACE(Bu::String("Stream=%1 - pStream->iSize(%2) += iAmnt(%3)").arg(pStream->iId).arg( pStream->iSize ).arg(iAmnt).end()); | ||
208 | pStream->iSize += iAmnt; | 212 | pStream->iSize += iAmnt; |
213 | TRACE(Bu::String("Stream=%1 - pStream->iSize = %2").arg(pStream->iId).arg( pStream->iSize ).end()); | ||
209 | rMyriad.headerChanged(); | 214 | rMyriad.headerChanged(); |
210 | pBuf = &((char *)pBuf)[iAmnt]; | 215 | pBuf = &((char *)pBuf)[iAmnt]; |
211 | iLeft -= iAmnt; | 216 | iLeft -= iAmnt; |