1 /* 2 * Copyright (c) 2014-2017 Intel, Inc. All rights reserved. 3 * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. 4 * $COPYRIGHT$ 5 * 6 * Additional copyrights may follow 7 * 8 * $HEADER$ 9 */ 10 11 #ifndef PMIX_PROGRESS_THREADS_H 12 #define PMIX_PROGRESS_THREADS_H 13 14 #include "pmix_config.h" 15 16 #include <pthread.h> 17 #include PMIX_EVENT_HEADER 18 19 #include "src/include/types.h" 20 21 /** 22 * Initialize a progress thread name; if a progress thread is not 23 * already associated with that name, start a progress thread. 24 * 25 * If you have general events that need to run in *a* progress thread 26 * (but not necessarily a your own, dedicated progress thread), pass 27 * NULL the "name" argument to the pmix_progress_thead_init() function 28 * to glom on to the general PMIX-wide progress thread. 29 * 30 * If a name is passed that was already used in a prior call to 31 * pmix_progress_thread_init(), the event base associated with that 32 * already-running progress thread will be returned (i.e., no new 33 * progress thread will be started). 34 */ 35 pmix_event_base_t *pmix_progress_thread_init(const char *name); 36 37 /** 38 * Stop a progress thread name (reference counted). 39 * 40 * Once this function is invoked as many times as 41 * pmix_progress_thread_init() was invoked on this name (or NULL), the 42 * progress function is shut down. 43 * it is destroyed. 44 * 45 * Will return PMIX_ERR_NOT_FOUND if the progress thread name does not 46 * exist; PMIX_SUCCESS otherwise. 47 */ 48 int pmix_progress_thread_stop(const char *name); 49 50 /** 51 * Finalize a progress thread name (reference counted). 52 * 53 * Once this function is invoked after pmix_progress_thread_stop() has been called 54 * as many times as pmix_progress_thread_init() was invoked on this name (or NULL), 55 * the event base associated with it is destroyed. 56 * 57 * Will return PMIX_ERR_NOT_FOUND if the progress thread name does not 58 * exist; PMIX_SUCCESS otherwise. 59 */ 60 int pmix_progress_thread_finalize(const char *name); 61 62 /** 63 * Temporarily pause the progress thread associated with this name. 64 * 65 * This function does not destroy the event base associated with this 66 * progress thread name, but it does stop processing all events on 67 * that event base until pmix_progress_thread_resume() is invoked on 68 * that name. 69 * 70 * Will return PMIX_ERR_NOT_FOUND if the progress thread name does not 71 * exist; PMIX_SUCCESS otherwise. 72 */ 73 int pmix_progress_thread_pause(const char *name); 74 75 /** 76 * Restart a previously-paused progress thread associated with this 77 * name. 78 * 79 * Will return PMIX_ERR_NOT_FOUND if the progress thread name does not 80 * exist; PMIX_SUCCESS otherwise. 81 */ 82 int pmix_progress_thread_resume(const char *name); 83 84 #endif