curl_multi_wakeup.3 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. .\" generated by cd2nroff 0.1 from curl_multi_wakeup.md
  2. .TH curl_multi_wakeup 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_multi_wakeup \- wake up a sleeping curl_multi_poll call
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLMcode curl_multi_wakeup(CURLM *multi_handle);
  9. .fi
  10. .SH DESCRIPTION
  11. This function can be called from any thread and it wakes up a sleeping
  12. \fIcurl_multi_poll(3)\fP call that is currently (or is about to be) waiting
  13. for activity or a timeout.
  14. If the function is called when there is no \fIcurl_multi_poll(3)\fP call, it
  15. causes the next call to return immediately.
  16. Calling this function only guarantees to wake up the current (or the next if
  17. there is no current) \fIcurl_multi_poll(3)\fP call, which means it is possible
  18. that multiple calls to this function wake up the same waiting operation.
  19. This function has no effect on \fIcurl_multi_wait(3)\fP calls.
  20. .SH PROTOCOLS
  21. This functionality affects all supported protocols
  22. .SH EXAMPLE
  23. .nf
  24. extern int time_to_die(void);
  25. extern int set_something_to_signal_thread_1_to_exit(void);
  26. extern int decide_to_stop_thread1();
  27. int main(void)
  28. {
  29. CURL *easy;
  30. CURLM *multi;
  31. int still_running;
  32. /* add the individual easy handle */
  33. curl_multi_add_handle(multi, easy);
  34. /* this is thread 1 */
  35. do {
  36. CURLMcode mc;
  37. int numfds;
  38. mc = curl_multi_perform(multi, &still_running);
  39. if(mc == CURLM_OK) {
  40. /* wait for activity, timeout or wakeup */
  41. mc = curl_multi_poll(multi, NULL, 0, 10000, &numfds);
  42. }
  43. if(time_to_die())
  44. return 1;
  45. } while(still_running);
  46. curl_multi_remove_handle(multi, easy);
  47. /* this is thread 2 */
  48. if(decide_to_stop_thread1()) {
  49. set_something_to_signal_thread_1_to_exit();
  50. curl_multi_wakeup(multi);
  51. }
  52. }
  53. .fi
  54. .SH AVAILABILITY
  55. Added in curl 7.68.0
  56. .SH RETURN VALUE
  57. CURLMcode type, general libcurl multi interface error code.
  58. .SH SEE ALSO
  59. .BR curl_multi_poll (3),
  60. .BR curl_multi_wait (3)