imgtools/romtools/rofsbuild/r_rofs.cpp
changeset 691 9eeecb73a5d4
parent 654 7c11c3d8d025
child 692 1dfff72f0961
equal deleted inserted replaced
690:c67de7b29582 691:9eeecb73a5d4
   261 	Print(ELog, "Vendor ID:               %08x\n", aHdr->iS.iVendorId);
   261 	Print(ELog, "Vendor ID:               %08x\n", aHdr->iS.iVendorId);
   262 	Print(ELog, "Priority:                %d\n\n", aHdr->iProcessPriority);
   262 	Print(ELog, "Priority:                %d\n\n", aHdr->iProcessPriority);
   263 }
   263 }
   264 class Worker : public boost::thread {
   264 class Worker : public boost::thread {
   265     public:
   265     public:
       
   266     static boost::mutex iOutputMutex;
   266     static void thrd_func(E32Rofs* rofs){
   267     static void thrd_func(E32Rofs* rofs){
   267         CBytePair bpe;
   268         CBytePair bpe;
   268 
   269 
   269         bool deferred = false;
   270         bool deferred = false;
   270         TPlacingSection* p = rofs->GetFileNode(deferred);
   271         TPlacingSection* p = rofs->GetFileNode(deferred);
   272             if(!deferred) {
   273             if(!deferred) {
   273                 p->len = p->node->PlaceFile(p->buf, (TUint32)-1, 0, &bpe);
   274                 p->len = p->node->PlaceFile(p->buf, (TUint32)-1, 0, &bpe);
   274                 //no symbol for hidden file
   275                 //no symbol for hidden file
   275                 if(rofs->iSymGen && !p->node->iEntry->iHidden)
   276                 if(rofs->iSymGen && !p->node->iEntry->iHidden)
   276                     rofs->iSymGen->AddFile(p->node->iEntry->iFileName,(p->node->iEntry->iCompressEnabled|| p->node->iEntry->iExecutable));
   277                     rofs->iSymGen->AddFile(p->node->iEntry->iFileName,(p->node->iEntry->iCompressEnabled|| p->node->iEntry->iExecutable));
       
   278 	        boost::mutex::scoped_lock lock(iOutputMutex);
       
   279 		p->node->FlushLogMessages();
   277             }
   280             }
   278             p = rofs->GetFileNode(deferred);
   281             p = rofs->GetFileNode(deferred);
   279         }
   282         }
   280         rofs->ArriveDeferPoint();
   283         rofs->ArriveDeferPoint();
   281         p = rofs->GetDeferredJob();
   284         p = rofs->GetDeferredJob();
   285         }
   288         }
   286     }
   289     }
   287     Worker(E32Rofs* rofs) : boost::thread(thrd_func,rofs) {
   290     Worker(E32Rofs* rofs) : boost::thread(thrd_func,rofs) {
   288     }
   291     }
   289 };
   292 };
       
   293 
       
   294 boost::mutex Worker::iOutputMutex;
   290 
   295 
   291 TPlacingSection* E32Rofs::GetFileNode(bool &aDeferred) {
   296 TPlacingSection* E32Rofs::GetFileNode(bool &aDeferred) {
   292 	//get a node from the node list, the node list is protected by mutex iMuxTree.
   297 	//get a node from the node list, the node list is protected by mutex iMuxTree.
   293 	//The iMuxTree also helps to make sure the order in iVPS is consistent with the node list.
   298 	//The iMuxTree also helps to make sure the order in iVPS is consistent with the node list.
   294 	//And this is the guarantee of same outputs regardless of how many threads being used.
   299 	//And this is the guarantee of same outputs regardless of how many threads being used.