2
0

curl_multi_wakeup.3 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" **************************************************************************
  22. .TH curl_multi_wakeup 3 "17 Nov 2019" "libcurl 7.68.0" "libcurl Manual"
  23. .SH NAME
  24. curl_multi_wakeup - wakes up a sleeping curl_multi_poll call
  25. .SH SYNOPSIS
  26. .nf
  27. #include <curl/curl.h>
  28. CURLMcode curl_multi_wakeup(CURLM *multi_handle);
  29. .fi
  30. .SH DESCRIPTION
  31. This function can be called from any thread and it wakes up a
  32. sleeping \fIcurl_multi_poll(3)\fP call that is currently (or will be)
  33. waiting for activity or a timeout.
  34. If the function is called when there is no \fIcurl_multi_poll(3)\fP call,
  35. it will cause the next call to return immediately.
  36. Calling this function only guarantees to wake up the current (or the next
  37. if there is no current) \fIcurl_multi_poll(3)\fP call, which means it is
  38. possible that multiple calls to this function will wake up the same waiting
  39. operation.
  40. This function has no effect on \fIcurl_multi_wait(3)\fP calls.
  41. .SH EXAMPLE
  42. .nf
  43. CURL *easy_handle;
  44. CURLM *multi_handle;
  45. /* add the individual easy handle */
  46. curl_multi_add_handle(multi_handle, easy_handle);
  47. /* this is thread 1 */
  48. do {
  49. CURLMcode mc;
  50. int numfds;
  51. mc = curl_multi_perform(multi_handle, &still_running);
  52. if(mc == CURLM_OK) {
  53. /* wait for activity, timeout or wakeup */
  54. mc = curl_multi_poll(multi_handle, NULL, 0, 10000, &numfds);
  55. }
  56. if(time_to_die())
  57. exit(1);
  58. } while(still_running);
  59. curl_multi_remove_handle(multi_handle, easy_handle);
  60. /* this is thread 2 */
  61. if(something makes us decide to stop thread 1) {
  62. set_something_to_signal_thread_1_to_exit();
  63. curl_multi_wakeup(multi_handle);
  64. }
  65. .fi
  66. .SH AVAILABILITY
  67. Added in 7.68.0
  68. .SH RETURN VALUE
  69. CURLMcode type, general libcurl multi interface error code.
  70. .SH "SEE ALSO"
  71. .BR curl_multi_poll "(3), " curl_multi_wait "(3)"