vcglib/apps/nexus/preload.h

50 lines
693 B
C
Raw Normal View History

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-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