diff options
author | Not Zed <NotZed@HelixCode.com> | 2000-12-24 08:58:02 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2000-12-24 08:58:02 +0800 |
commit | 5674966eeb7eecfa109ad419f1c997dba69ff0af (patch) | |
tree | a439ac65139c39f3f551573b1c9f14a8e56b1c82 /libibex/testindex.c | |
parent | d5b5b5f0979f0819561fbec36a417a6dcfc3d4d5 (diff) | |
download | gsoc2013-evolution-5674966eeb7eecfa109ad419f1c997dba69ff0af.tar.gz gsoc2013-evolution-5674966eeb7eecfa109ad419f1c997dba69ff0af.tar.zst gsoc2013-evolution-5674966eeb7eecfa109ad419f1c997dba69ff0af.zip |
Merge from camel-mt-branch.
2000-12-24 Not Zed <NotZed@HelixCode.com>
* Merge from camel-mt-branch.
svn path=/trunk/; revision=7152
Diffstat (limited to 'libibex/testindex.c')
-rw-r--r-- | libibex/testindex.c | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/libibex/testindex.c b/libibex/testindex.c index e21d73ff06..a3b6a9ce03 100644 --- a/libibex/testindex.c +++ b/libibex/testindex.c @@ -6,6 +6,10 @@ #include <string.h> #include "ibex_internal.h" +#ifdef ENABLE_THREADS +#include <pthread.h> +#endif + void word_index_mem_dump_info(struct _IBEXWord *idx); /* @@ -69,6 +73,29 @@ static char *getword(GPtrArray *words, float m, float s) return words->pdata[index]; } +#ifdef ENABLE_THREADS +int do_read_words; + +static void * +read_words(void *in) +{ + ibex *ib = in; + GPtrArray *a; + int lastlen = 0; + int i; + + while (do_read_words) { + a = ibex_find(ib, "joneses"); + if (a->len != lastlen) { + printf("Found %d joneses!\n", a->len); + lastlen = a->len; + } + for (i=0;i<a->len;i++) + g_free(a->pdata[i]); + g_ptr_array_free(a, TRUE); + } +} +#endif int main(int argc, char **argv) { @@ -83,9 +110,15 @@ int main(int argc, char **argv) int files; char *dict; +#ifdef ENABLE_THREADS + pthread_t id; + + g_thread_init(0); +#endif + srand(0xABADF00D); - files = 80000; + files = 8000; dict = "/usr/dict/words"; /* read words into an array */ @@ -119,6 +152,10 @@ int main(int argc, char **argv) return 1; } +#ifdef ENABLE_THREADS + do_read_words = 1; + pthread_create(&id, 0, read_words, ib); +#endif printf("Adding %d files\n", files); /* simulate adding new words to a bunch of files */ @@ -151,6 +188,11 @@ int main(int argc, char **argv) word_index_mem_dump_info(ib->words); +#ifdef ENABLE_THREADS + do_read_words = 0; + pthread_join(id, 0); +#endif + ibex_close(ib); return 0; |