Skip to content
Extraits de code Groupes Projets
Vérifiée Valider b60b92ba rédigé par Kubat's avatar Kubat
Parcourir les fichiers

CACHE: Add a bit of sleep to not burn the hard-drive

parent 9901d2eb
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion!157Caching for karas & refactor & others
......@@ -173,6 +173,17 @@ end:
static pthread_t ___thread_wlaker;
/* Sleep a bit, to not overuse ressources */
PRIVATE_FUNCTION void
___sleep(void)
{
struct timespec time_sleep = {
.tv_sec = 0,
.tv_nsec = 100000000L,
}; /* Sleep for 0.1s */
nanosleep(&time_sleep, NULL); /* Sleep a bit, better for Hard drive */
}
PRIVATE_FUNCTION void *
___caching_walker(void *args)
{
......@@ -190,6 +201,8 @@ ___caching_walker(void *args)
for (size_t index = 0; index < ids_count; ++index) {
database_cache_kara(db, ids[index]);
if ((index % 10) == 0)
___sleep();
}
LOG_INFO("CACHE", "Finished caching %ld karas", ids_count);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter