creaImageIO_lib
creaImageIO::ThreadedImageReader Class Reference
Inheritance diagram for creaImageIO::ThreadedImageReader:
Collaboration diagram for creaImageIO::ThreadedImageReader:

Classes

struct  deleter
 

Public Member Functions

 ThreadedImageReader (MultiThreadImageReader *tir)
 
void * Entry ()
 
void OnExit ()
 
vtkImageData * Read (const std::string &filename)
 
 ThreadedImageReader (MultiThreadImageReader *tir)
 
void * Entry ()
 
void OnExit ()
 
vtkImageData * Read (const std::string &filename)
 

Private Attributes

ImageReader mReader
 
MultiThreadImageReadermMultiThreadImageReader
 

Friends

struct deleter
 

Detailed Description

Definition at line 54 of file creaImageIOMultiThreadImageReader.cpp.

Constructor & Destructor Documentation

creaImageIO::ThreadedImageReader::ThreadedImageReader ( MultiThreadImageReader tir)
inline

Definition at line 57 of file creaImageIOMultiThreadImageReader.cpp.

58  :
{}
creaImageIO::ThreadedImageReader::ThreadedImageReader ( MultiThreadImageReader tir)
inline

Definition at line 57 of file creaImageIOQMultiThreadImageReader.cpp.

58  :
{}

Member Function Documentation

void * creaImageIO::ThreadedImageReader::Entry ( )

Definition at line 589 of file creaImageIOMultiThreadImageReader.cpp.

References creaImageIO::MultiThreadImageReader::ImageToLoad::GetFilename(), creaImageIO::MultiThreadImageReader::mImages, mMultiThreadImageReader, creaImageIO::MultiThreadImageReader::mQueue, creaImageIO::MultiThreadImageReaderUser::MultiThreadImageReaderEventLock(), creaImageIO::MultiThreadImageReaderUser::MultiThreadImageReaderEventUnlock(), Read(), creaImageIO::MultiThreadImageReader::ImageToLoad::SetImage(), creaImageIO::MultiThreadImageReader::SignalImageRead(), and creaImageIO::MultiThreadImageReaderUser::ThreadedReaderStarted.

590  {
591  // std::cout << "### Thread "<<GetCurrentId()<<"::Entry()"
592  // << std::endl;
593 
594  mMultiThreadImageReader->MultiThreadImageReaderSendEvent
595  ("",
597  0);
598 
599  // While was not deleted
600  while (!TestDestroy())
601  {
602  //std::cout << "### Thread "<<GetCurrentId()<<" still alive" << std::endl;
603 
604  // Lock the mutex
606  //mMutex.Lock();
607  // If image in queue
608  if (mMultiThreadImageReader->mQueue.size()>0)
609  {
611  mMultiThreadImageReader->mQueue.remove_top();
612 
614  //mMutex.Unlock();
615 
616 
617  // std::cout << "### Thread "<<GetCurrentId()<<" : reading '"
618  // << i->GetFilename() << "'" << std::endl;
619 
620  // Do the job
621  vtkImageData* im = Read(i->GetFilename());
622 
623  // Store it in the map
625  //mMutex.Lock();
626  MultiThreadImageReader::ImageToLoad itl(0,i->GetFilename());
627  MultiThreadImageReader::ImageMapType::iterator it =
628  mMultiThreadImageReader->mImages.find(&itl);
630  pitl = const_cast<MultiThreadImageReader::ImageToLoadPtr>
631  (it->first);
632  pitl->SetImage(im);
633  mMultiThreadImageReader->SignalImageRead(pitl,true);//i->GetFilename());
635 
636  // std::cout << "### Thread "<<GetCurrentId()<<" : reading '"
637  // << i->GetFilename() << "' : DONE" << std::endl;
638 
639  }
640  else
641  {
643  //mMutex.Unlock();
644  // Wait a little to avoid blocking
645  Sleep(10);
646  }
647  };
648  // std::cout << "### Thread "<<GetCurrentId()<<" stopping"
649  // << std::endl;
650 
651  return 0;
652  }

Here is the call graph for this function:

void* creaImageIO::ThreadedImageReader::Entry ( )
void creaImageIO::ThreadedImageReader::OnExit ( )
void creaImageIO::ThreadedImageReader::OnExit ( )

Definition at line 656 of file creaImageIOMultiThreadImageReader.cpp.

References mMultiThreadImageReader, and creaImageIO::MultiThreadImageReaderUser::ThreadedReaderStopped.

657  {
658  mMultiThreadImageReader->MultiThreadImageReaderSendEvent
659  ("",
661  0);
662  }
vtkImageData * creaImageIO::ThreadedImageReader::Read ( const std::string &  filename)

Definition at line 666 of file creaImageIOMultiThreadImageReader.cpp.

References mReader, and creaImageIO::ImageReader::ReadImage().

Referenced by Entry().

667  {
668  return mReader.ReadImage(filename);
669  }

Here is the call graph for this function:

Here is the caller graph for this function:

vtkImageData* creaImageIO::ThreadedImageReader::Read ( const std::string &  filename)

Friends And Related Function Documentation

deleter
friend

Definition at line 73 of file creaImageIOMultiThreadImageReader.cpp.

Member Data Documentation

MultiThreadImageReader * creaImageIO::ThreadedImageReader::mMultiThreadImageReader
private

Definition at line 78 of file creaImageIOMultiThreadImageReader.cpp.

Referenced by Entry(), and OnExit().

ImageReader creaImageIO::ThreadedImageReader::mReader
private

Definition at line 77 of file creaImageIOMultiThreadImageReader.cpp.

Referenced by Read().


The documentation for this class was generated from the following files: