curl_multi_wakeup.3 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) 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. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .TH curl_multi_wakeup 3 "17 Nov 2019" "libcurl" "libcurl"
  25. .SH NAME
  26. curl_multi_wakeup - wakes up a sleeping curl_multi_poll call
  27. .SH SYNOPSIS
  28. .nf
  29. #include <curl/curl.h>
  30. CURLMcode curl_multi_wakeup(CURLM *multi_handle);
  31. .fi
  32. .SH DESCRIPTION
  33. This function can be called from any thread and it wakes up a sleeping
  34. \fIcurl_multi_poll(3)\fP call that is currently (or is about to be) waiting
  35. for activity or a timeout.
  36. If the function is called when there is no \fIcurl_multi_poll(3)\fP call, it
  37. causes the next call to return immediately.
  38. Calling this function only guarantees to wake up the current (or the next if
  39. there is no current) \fIcurl_multi_poll(3)\fP call, which means it is possible
  40. that multiple calls to this function wake up the same waiting operation.
  41. This function has no effect on \fIcurl_multi_wait(3)\fP calls.
  42. .SH EXAMPLE
  43. .nf
  44. CURL *easy_handle;
  45. CURLM *multi_handle;
  46. /* add the individual easy handle */
  47. curl_multi_add_handle(multi_handle, easy_handle);
  48. /* this is thread 1 */
  49. do {
  50. CURLMcode mc;
  51. int numfds;
  52. mc = curl_multi_perform(multi_handle, &still_running);
  53. if(mc == CURLM_OK) {
  54. /* wait for activity, timeout or wakeup */
  55. mc = curl_multi_poll(multi_handle, NULL, 0, 10000, &numfds);
  56. }
  57. if(time_to_die())
  58. exit(1);
  59. } while(still_running);
  60. curl_multi_remove_handle(multi_handle, easy_handle);
  61. /* this is thread 2 */
  62. if(something makes us decide to stop thread 1) {
  63. set_something_to_signal_thread_1_to_exit();
  64. curl_multi_wakeup(multi_handle);
  65. }
  66. .fi
  67. .SH AVAILABILITY
  68. Added in 7.68.0
  69. .SH RETURN VALUE
  70. CURLMcode type, general libcurl multi interface error code.
  71. .SH "SEE ALSO"
  72. .BR curl_multi_poll "(3), " curl_multi_wait "(3)"