2005-02-08 13:43:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2005-02-17 16:39:44 +01:00
|
|
|
Revision 1.4 2005/02/08 12:43:03 ponchio
|
|
|
|
Added copyright
|
|
|
|
|
2005-02-08 13:43:03 +01:00
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
#ifndef NXS_PRELOAD_H
|
|
|
|
#define NXS_PRELOAD_H
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include <ptypes/pasync.h>
|
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
#include "extraction.h"
|
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
namespace nxs {
|
|
|
|
|
|
|
|
class NexusMt;
|
|
|
|
|
|
|
|
class Preload: public pt::thread{
|
|
|
|
public:
|
|
|
|
|
|
|
|
NexusMt *mt;
|
|
|
|
|
|
|
|
pt::mutex lock;
|
2005-02-01 17:42:30 +01:00
|
|
|
pt::trigger trigger;
|
2005-01-14 16:41:10 +01:00
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
std::vector<Item> queue;
|
2005-01-14 16:41:10 +01:00
|
|
|
|
2005-02-17 16:39:44 +01:00
|
|
|
unsigned int disk; //kbytes readed from disk
|
|
|
|
unsigned int total_disk;
|
2005-02-03 13:35:01 +01:00
|
|
|
Preload(): thread(false), trigger(false, false) {}
|
2005-01-14 16:41:10 +01:00
|
|
|
~Preload() {
|
|
|
|
waitfor();
|
|
|
|
}
|
|
|
|
|
|
|
|
void execute();
|
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
void post(std::vector<Item> &patches) {
|
|
|
|
trigger.reset();
|
2005-01-14 16:41:10 +01:00
|
|
|
lock.enter();
|
2005-02-03 13:35:01 +01:00
|
|
|
|
|
|
|
queue.reserve(patches.size());
|
|
|
|
for(int i = patches.size() -1; i >= 0; i--)
|
|
|
|
queue.push_back(patches[i]);
|
|
|
|
|
2005-02-01 17:42:30 +01:00
|
|
|
trigger.post();
|
2005-01-14 16:41:10 +01:00
|
|
|
lock.leave();
|
|
|
|
}
|
|
|
|
|
|
|
|
void cleanup() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|