Hydra 0.20
hydra.src/desktop/FutureLoader.h
00001 
00002 /*
00003  * Copyright (c) 2010 Aleksander B. Demko
00004  * This source code is distributed under the MIT license.
00005  * See the accompanying file LICENSE.MIT.txt for details.
00006  */
00007 
00008 #ifndef __INCLUDED_FUTURELOADER_H__
00009 #define __INCLUDED_FUTURELOADER_H__
00010 
00011 #include <desktop/ThumbCache.h>
00012 #include <desktop/View.h>
00013 
00014 #include <QMutex>
00015 
00016 namespace desktop
00017 {
00018   class FutureLoader;
00019 }
00020 
00021 /**
00022  * This, via QThreadPool will fill out the unloaded hash and thumnb entries
00023  * of a FileList.
00024  *
00025  * @author Aleksander Demko
00026  */ 
00027 class desktop::FutureLoader : public FileListListener
00028 {
00029   public:
00030     /// constructor
00031     FutureLoader(ThreadedThumbCache *thumbcache, FileList *flist);
00032     /// destructor
00033     ~FutureLoader();
00034 
00035     virtual void onBaseChange(FileList *fl) { start(); }
00036 
00037     /// signals all the jobs to die quickly
00038     void flushJobs(void);
00039 
00040     // start processing the list
00041     // if its already running, this function does nothing
00042     void start(void);
00043 
00044   private:
00045     void workerFunc(void);
00046     void mainFunc(void);
00047 
00048   private:
00049     ThreadedThumbCache *dm_thumbcache;
00050     FileList *dm_flist;
00051 
00052     QMutex dm_lock;
00053     bool dm_running;
00054     bool dm_quit; // should the running thread (if any) quit right now
00055     bool dm_hashstage;
00056 
00057     int dm_lastdoneindex;
00058 };
00059 
00060 #endif
00061 
 All Classes Namespaces Functions Variables