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