1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_multi_wakeup 5Section: 3 6Source: libcurl 7See-also: 8 - curl_multi_poll (3) 9 - curl_multi_wait (3) 10--- 11 12# NAME 13 14curl_multi_wakeup - wakes up a sleeping curl_multi_poll call 15 16# SYNOPSIS 17 18~~~c 19#include <curl/curl.h> 20 21CURLMcode curl_multi_wakeup(CURLM *multi_handle); 22~~~ 23 24# DESCRIPTION 25 26This function can be called from any thread and it wakes up a sleeping 27curl_multi_poll(3) call that is currently (or is about to be) waiting 28for activity or a timeout. 29 30If the function is called when there is no curl_multi_poll(3) call, it 31causes the next call to return immediately. 32 33Calling this function only guarantees to wake up the current (or the next if 34there is no current) curl_multi_poll(3) call, which means it is possible 35that multiple calls to this function wake up the same waiting operation. 36 37This function has no effect on curl_multi_wait(3) calls. 38 39# EXAMPLE 40 41~~~c 42extern int time_to_die(void); 43extern int set_something_to_signal_thread_1_to_exit(void); 44extern int decide_to_stop_thread1(); 45 46int main(void) 47{ 48 CURL *easy; 49 CURLM *multi; 50 int still_running; 51 52 /* add the individual easy handle */ 53 curl_multi_add_handle(multi, easy); 54 55 /* this is thread 1 */ 56 do { 57 CURLMcode mc; 58 int numfds; 59 60 mc = curl_multi_perform(multi, &still_running); 61 62 if(mc == CURLM_OK) { 63 /* wait for activity, timeout or wakeup */ 64 mc = curl_multi_poll(multi, NULL, 0, 10000, &numfds); 65 } 66 67 if(time_to_die()) 68 return 1; 69 70 } while(still_running); 71 72 curl_multi_remove_handle(multi, easy); 73 74 /* this is thread 2 */ 75 76 if(decide_to_stop_thread1()) { 77 78 set_something_to_signal_thread_1_to_exit(); 79 80 curl_multi_wakeup(multi); 81 } 82} 83~~~ 84 85# AVAILABILITY 86 87Added in 7.68.0 88 89# RETURN VALUE 90 91CURLMcode type, general libcurl multi interface error code. 92