forked from len0rd/rockbox
Yield regularly during commits so the UI doesn't lock up
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12709 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9ab9f91691
commit
6d7f68c030
1 changed files with 27 additions and 15 deletions
|
@ -81,6 +81,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#define yield() do { } while(0)
|
#define yield() do { } while(0)
|
||||||
#define sim_sleep(timeout) do { } while(0)
|
#define sim_sleep(timeout) do { } while(0)
|
||||||
|
#define do_timed_yield() do { } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -306,12 +307,26 @@ static int open_tag_fd(struct tagcache_header *hdr, int tag, bool write)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef __PCTOOL__
|
||||||
|
static bool do_timed_yield(void)
|
||||||
|
{
|
||||||
|
/* Sorting can lock up for quite a while, so yield occasionally */
|
||||||
|
static long wakeup_tick = 0;
|
||||||
|
if (current_tick >= wakeup_tick)
|
||||||
|
{
|
||||||
|
wakeup_tick = current_tick + (HZ/4);
|
||||||
|
yield();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
|
#if defined(HAVE_TC_RAMCACHE) && defined(HAVE_DIRCACHE)
|
||||||
static long find_entry_ram(const char *filename,
|
static long find_entry_ram(const char *filename,
|
||||||
const struct dircache_entry *dc)
|
const struct dircache_entry *dc)
|
||||||
{
|
{
|
||||||
static long last_pos = 0;
|
static long last_pos = 0;
|
||||||
int counter = 0;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Check if we tagcache is loaded into ram. */
|
/* Check if we tagcache is loaded into ram. */
|
||||||
|
@ -342,11 +357,7 @@ static long find_entry_ram(const char *filename,
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (++counter == 100)
|
do_timed_yield();
|
||||||
{
|
|
||||||
yield();
|
|
||||||
counter = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_pos > 0)
|
if (last_pos > 0)
|
||||||
|
@ -1737,6 +1748,8 @@ static bool tempbuf_insert(char *str, int id, int idx_id, bool unique)
|
||||||
|
|
||||||
static int compare(const void *p1, const void *p2)
|
static int compare(const void *p1, const void *p2)
|
||||||
{
|
{
|
||||||
|
do_timed_yield();
|
||||||
|
|
||||||
struct tempbuf_searchidx *e1 = (struct tempbuf_searchidx *)p1;
|
struct tempbuf_searchidx *e1 = (struct tempbuf_searchidx *)p1;
|
||||||
struct tempbuf_searchidx *e2 = (struct tempbuf_searchidx *)p2;
|
struct tempbuf_searchidx *e2 = (struct tempbuf_searchidx *)p2;
|
||||||
|
|
||||||
|
@ -1790,6 +1803,8 @@ static int tempbuf_sort(int fd)
|
||||||
idlist = idlist->next;
|
idlist = idlist->next;
|
||||||
idlist->id = i;
|
idlist->id = i;
|
||||||
idlist->next = NULL;
|
idlist->next = NULL;
|
||||||
|
|
||||||
|
do_timed_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(index, tempbufidx, sizeof(struct tempbuf_searchidx), compare);
|
qsort(index, tempbufidx, sizeof(struct tempbuf_searchidx), compare);
|
||||||
|
@ -2115,7 +2130,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
close(fd);
|
close(fd);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
yield();
|
do_timed_yield();
|
||||||
}
|
}
|
||||||
logf("done");
|
logf("done");
|
||||||
}
|
}
|
||||||
|
@ -2260,7 +2275,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
/* Skip to next. */
|
/* Skip to next. */
|
||||||
lseek(tmpfd, entry.data_length - entry.tag_offset[index_type] -
|
lseek(tmpfd, entry.data_length - entry.tag_offset[index_type] -
|
||||||
entry.tag_length[index_type], SEEK_CUR);
|
entry.tag_length[index_type], SEEK_CUR);
|
||||||
yield();
|
do_timed_yield();
|
||||||
}
|
}
|
||||||
logf("done");
|
logf("done");
|
||||||
|
|
||||||
|
@ -2312,7 +2327,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
goto error_exit;
|
goto error_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield();
|
do_timed_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write back the updated index. */
|
/* Write back the updated index. */
|
||||||
|
@ -2431,7 +2446,7 @@ static int build_index(int index_type, struct tagcache_header *h, int tmpfd)
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield();
|
do_timed_yield();
|
||||||
}
|
}
|
||||||
logf("done");
|
logf("done");
|
||||||
|
|
||||||
|
@ -3016,7 +3031,7 @@ bool tagcache_create_changelog(struct tagcache_search *tcs)
|
||||||
}
|
}
|
||||||
|
|
||||||
write(clfd, "\n", 1);
|
write(clfd, "\n", 1);
|
||||||
yield();
|
do_timed_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
close(clfd);
|
close(clfd);
|
||||||
|
@ -3278,7 +3293,6 @@ static bool load_tagcache(void)
|
||||||
int rc, fd;
|
int rc, fd;
|
||||||
char *p;
|
char *p;
|
||||||
int i, tag;
|
int i, tag;
|
||||||
int yield_count = 0;
|
|
||||||
|
|
||||||
# ifdef HAVE_DIRCACHE
|
# ifdef HAVE_DIRCACHE
|
||||||
while (dircache_is_initializing())
|
while (dircache_is_initializing())
|
||||||
|
@ -3355,13 +3369,11 @@ static bool load_tagcache(void)
|
||||||
{
|
{
|
||||||
long pos;
|
long pos;
|
||||||
|
|
||||||
if (yield_count++ == 100)
|
if (do_timed_yield())
|
||||||
{
|
{
|
||||||
yield();
|
|
||||||
/* Abort if we got a critical event in queue */
|
/* Abort if we got a critical event in queue */
|
||||||
if (check_event_queue())
|
if (check_event_queue())
|
||||||
return false;
|
return false;
|
||||||
yield_count = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fe = (struct tagfile_entry *)p;
|
fe = (struct tagfile_entry *)p;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue