Scroom  0.14
DataFetcher Class Reference
Collaboration diagram for DataFetcher:
Collaboration graph

Public Member Functions

 DataFetcher (Layer::Ptr layer, int height, int horTileCount, int verTileCount, SourcePresentation::Ptr sp, ThreadPool::WeakQueue::Ptr queue, std::function< void()> on_finished)
 DataFetcher. More...
 
void operator() ()
 

Private Attributes

Layer::Ptr layer
 
int height
 
int horTileCount
 
int verTileCount
 
int currentRow {0}
 
SourcePresentation::Ptr sp
 
ThreadPool::Ptr threadPool
 
ThreadPool::WeakQueue::Ptr queue
 
std::function< void()> on_finished
 

Constructor & Destructor Documentation

◆ DataFetcher()

DataFetcher::DataFetcher ( Layer::Ptr  layer,
int  height,
int  horTileCount,
int  verTileCount,
SourcePresentation::Ptr  sp,
ThreadPool::WeakQueue::Ptr  queue,
std::function< void()>  on_finished 
)

DataFetcher.

199  : layer(std::move(layer_))
200  , height(height_)
201  , horTileCount(horTileCount_)
202  , verTileCount(verTileCount_)
203  , sp(std::move(sp_))
204  , threadPool(CpuBound())
205  , queue(std::move(queue_))
206  , on_finished(std::move(on_finished_))
207 {
208 }

Member Function Documentation

◆ operator()()

void DataFetcher::operator() ( )
211 {
213 
214  threadPool->schedule(qj, REDUCE_PRIO, queue);
215 
216  CompressedTileLine& tileLine = layer->getTileLine(currentRow);
217  std::vector<Tile::Ptr> tiles;
218  for(int x = 0; x < horTileCount; x++)
219  {
220  CompressedTile::Ptr const ti = tileLine[x];
221  Scroom::Utils::Stuff const s = ti->initialize();
222  tiles.push_back(ti->getTileSync());
223  }
224  const int lineCount = std::min(TILESIZE, height - currentRow * TILESIZE);
225 
226  sp->fillTiles(currentRow * TILESIZE, lineCount, TILESIZE, 0, tiles);
227 
228  for(int x = 0; x < horTileCount; x++)
229  {
230  tileLine[x]->reportFinished();
231  }
232 
233  currentRow++;
235  {
236  DataFetcher const successor(*this);
237  if(!qj->setWork(successor))
238  {
239  threadPool->schedule(successor, DATAFETCH_PRIO, queue);
240  }
241  }
242  else
243  {
244  sp->done();
245  on_finished();
246  }
247 }
Here is the call graph for this function:

Member Data Documentation

◆ currentRow

int DataFetcher::currentRow {0}
private

Referenced by operator()().

◆ height

int DataFetcher::height
private

Referenced by operator()().

◆ horTileCount

int DataFetcher::horTileCount
private

Referenced by operator()().

◆ layer

Layer::Ptr DataFetcher::layer
private

Referenced by operator()().

◆ on_finished

std::function<void()> DataFetcher::on_finished
private

Referenced by operator()().

◆ queue

ThreadPool::WeakQueue::Ptr DataFetcher::queue
private

Referenced by operator()().

◆ sp

SourcePresentation::Ptr DataFetcher::sp
private

Referenced by operator()().

◆ threadPool

ThreadPool::Ptr DataFetcher::threadPool
private

Referenced by operator()().

◆ verTileCount

int DataFetcher::verTileCount
private

Referenced by operator()().


The documentation for this class was generated from the following file:
DataFetcher::threadPool
ThreadPool::Ptr threadPool
Definition: layer.cc:51
DataFetcher::horTileCount
int horTileCount
Definition: layer.cc:47
QueueJumper::create
static Ptr create()
QueueJumper.
Definition: threadpoolimpl.cc:419
DataFetcher::verTileCount
int verTileCount
Definition: layer.cc:48
DataFetcher::layer
Layer::Ptr layer
Definition: layer.cc:45
QueueJumper::Ptr
boost::shared_ptr< QueueJumper > Ptr
Definition: threadpool.hh:537
CpuBound
ThreadPool::Ptr CpuBound()
Definition: threadpoolimpl.cc:452
DataFetcher::sp
SourcePresentation::Ptr sp
Definition: layer.cc:50
Scroom::Utils::Stuff
boost::shared_ptr< void > Stuff
Definition: stuff.hh:18
DataFetcher::currentRow
int currentRow
Definition: layer.cc:49
DataFetcher::on_finished
std::function< void()> on_finished
Definition: layer.cc:53
CompressedTile::Ptr
boost::shared_ptr< CompressedTile > Ptr
Definition: tiledbitmaplayer.hh:108
TILESIZE
#define TILESIZE
Definition: tiledbitmaplayer.hh:28
CompressedTileLine
std::vector< CompressedTile::Ptr > CompressedTileLine
Definition: tiledbitmaplayer.hh:237
DATAFETCH_PRIO
#define DATAFETCH_PRIO
Definition: local.hh:11
DataFetcher
Definition: layer.cc:42
DataFetcher::height
int height
Definition: layer.cc:46
REDUCE_PRIO
#define REDUCE_PRIO
Definition: local.hh:12
DataFetcher::queue
ThreadPool::WeakQueue::Ptr queue
Definition: layer.cc:52