1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-29 09:02:27 +02:00

When started, load all OPKs in a thread to boost startup time

This commit is contained in:
Paul Cercueil 2013-08-28 13:25:10 -04:00
parent 5d8fb6520f
commit 5c631d610e
2 changed files with 26 additions and 17 deletions

View File

@ -25,6 +25,7 @@
#include <algorithm>
#include <math.h>
#include <fstream>
#include <thread>
#include <unistd.h>
#ifdef HAVE_LIBOPK
@ -79,23 +80,8 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
readLinks();
#ifdef HAVE_LIBOPK
{
struct dirent *dptr;
DIR *dirp = opendir(CARD_ROOT);
if (dirp) {
while ((dptr = readdir(dirp))) {
if (dptr->d_type != DT_DIR)
continue;
if (!strcmp(dptr->d_name, ".") || !strcmp(dptr->d_name, ".."))
continue;
openPackagesFromDir((string) CARD_ROOT + "/" +
dptr->d_name + "/apps");
}
closedir(dirp);
}
}
std::thread t(&Menu::openAllPackages, this);
t.detach();
#endif
orderLinks();
@ -112,6 +98,27 @@ Menu::~Menu() {
delete *it;
}
#ifdef HAVE_LIBOPK
void Menu::openAllPackages(void)
{
struct dirent *dptr;
DIR *dirp = opendir(CARD_ROOT);
if (dirp) {
while ((dptr = readdir(dirp))) {
if (dptr->d_type != DT_DIR)
continue;
if (!strcmp(dptr->d_name, ".") || !strcmp(dptr->d_name, ".."))
continue;
openPackagesFromDir((string) CARD_ROOT + "/" +
dptr->d_name + "/apps");
}
closedir(dirp);
}
}
#endif
void Menu::readSections(std::string parentDir)
{
DIR *dirp;
@ -751,6 +758,7 @@ void Menu::readPackages(std::string parentDir)
}
openPackage(parentDir + '/' + dptr->d_name, false);
inject_user_event(); // Notify the InputManager for a repaint
}
closedir(dirp);

View File

@ -105,6 +105,7 @@ public:
#ifdef HAVE_LIBOPK
void openPackage(std::string path, bool order = true);
void openPackagesFromDir(std::string path);
void openAllPackages(void);
#ifdef ENABLE_INOTIFY
void removePackageLink(std::string path);
#endif