diff options
author | Thomas White <thomas.white@desy.de> | 2025-01-20 15:21:17 +0100 |
---|---|---|
committer | Thomas White <thomas.white@desy.de> | 2025-01-20 15:21:17 +0100 |
commit | 105f00f5fc2cc965f173ecfad4db2c6241b6e0d8 (patch) | |
tree | d23a34ec6ca11afdda81fdcd35b403845ccb8b95 /libcrystfel | |
parent | 41bd98f913dfc522e6ae0941396cb813f8a6663e (diff) | |
parent | 3e57aa731c8c38638d3323cee51157d469b7f956 (diff) |
Move "index this pattern" work to a separate thread
See merge request thomas.white/crystfel!43
Diffstat (limited to 'libcrystfel')
-rw-r--r-- | libcrystfel/src/index.c | 2 | ||||
-rw-r--r-- | libcrystfel/src/utils.c | 26 | ||||
-rw-r--r-- | libcrystfel/src/utils.h | 7 |
3 files changed, 20 insertions, 15 deletions
diff --git a/libcrystfel/src/index.c b/libcrystfel/src/index.c index cb77c0b2..10de4daf 100644 --- a/libcrystfel/src/index.c +++ b/libcrystfel/src/index.c @@ -1014,7 +1014,7 @@ void index_pattern_4(struct image *image, IndexingPrivate *ipriv, int *ping, done = finished_retry(ipriv->methods[n], ipriv->flags, r, image); if ( ntry > 5 ) done = 1; - notify_alive(); + if ( notify_alive() ) done = 1; } while ( !done ); diff --git a/libcrystfel/src/utils.c b/libcrystfel/src/utils.c index 96e2a371..dd390789 100644 --- a/libcrystfel/src/utils.c +++ b/libcrystfel/src/utils.c @@ -468,37 +468,41 @@ char *safe_strdup(const char *in) /* -------------------------------- Debugging ------------------------------- */ -static void set_last_task_dummy(const char *task) +static void set_last_task_dummy(const char *task, void *vp) { /* Do nothing */ } -static void notify_alive_dummy() +static int notify_alive_dummy(void *vp) { /* Do nothing */ + return 0; } struct _debugconf { - void (*set_last_task)(const char *task); - void (*notify_alive)(void); -} debug_conf = { set_last_task_dummy, notify_alive_dummy }; - -int set_debug_funcs(void (*slt)(const char *), - void (*ping)(void)) + void (*set_last_task)(const char *task, void *vp); + int (*notify_alive)(void *vp); + void *debug_data; +} debug_conf = { set_last_task_dummy, notify_alive_dummy, NULL }; + +int set_debug_funcs(void (*slt)(const char *, void *), + int (*ping)(void *), + void *vp) { debug_conf.set_last_task = slt; debug_conf.notify_alive = ping; + debug_conf.debug_data = vp; return 0; } void set_last_task(const char *task) { - debug_conf.set_last_task(task); + debug_conf.set_last_task(task, debug_conf.debug_data); } -void notify_alive() +int notify_alive() { - debug_conf.notify_alive(); + return debug_conf.notify_alive(debug_conf.debug_data); } diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index e295c40b..07a1e1a1 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -257,9 +257,10 @@ extern int set_mm_funcs(void *(*cfmalloc)(size_t size), /* -------------------------------- Debugging ------------------------------- */ extern void set_last_task(const char *task); -extern void notify_alive(void); -extern int set_debug_funcs(void (*slt)(const char *), - void (*ping)(void)); +extern int notify_alive(void); +extern int set_debug_funcs(void (*slt)(const char *, void *vp), + int (*ping)(void *vp), + void *debug_data); /* ------------------------------ File handling ----------------------------- */ |