+#include <QLinkedList>
+
+static const int maxSimultaneousProcesses = 100;
+
+class ProcessCache: QLinkedList<Repository *>
+{
+public:
+ void touch(Repository *repo)
+ {
+ remove(repo);
+
+ // if the cache is too big, remove from the front
+ while (size() >= maxSimultaneousProcesses)
+ takeFirst()->closeFastImport();
+
+ // append to the end
+ append(repo);
+ }
+
+ inline void remove(Repository *repo)
+ {
+ removeOne(repo);
+ }
+};
+static ProcessCache processCache;