quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

CURLSHOPT_LOCKFUNC.md (1885B)


      1 ---
      2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      3 SPDX-License-Identifier: curl
      4 Title: CURLSHOPT_LOCKFUNC
      5 Section: 3
      6 Source: libcurl
      7 See-also:
      8   - CURLSHOPT_UNLOCKFUNC (3)
      9   - curl_share_cleanup (3)
     10   - curl_share_init (3)
     11   - curl_share_setopt (3)
     12 Protocol:
     13   - All
     14 Added-in: 7.10.3
     15 ---
     16 
     17 # NAME
     18 
     19 CURLSHOPT_LOCKFUNC - mutex lock callback
     20 
     21 # SYNOPSIS
     22 
     23 ~~~c
     24 #include <curl/curl.h>
     25 
     26 void lockcb(CURL *handle, curl_lock_data data, curl_lock_access access,
     27             void *clientp);
     28 
     29 CURLSHcode curl_share_setopt(CURLSH *share, CURLSHOPT_LOCKFUNC, lockcb);
     30 ~~~
     31 
     32 # DESCRIPTION
     33 
     34 Set a mutex lock callback for the share object, to allow it to get used by
     35 multiple threads concurrently. There is a corresponding
     36 CURLSHOPT_UNLOCKFUNC(3) callback called when the mutex is again released.
     37 
     38 The *lockcb* argument must be a pointer to a function matching the
     39 prototype shown above. The arguments to the callback are:
     40 
     41 *handle* is the currently active easy handle in use when the share object
     42 is intended to get used.
     43 
     44 The *data* argument tells what kind of data libcurl wants to lock. Make
     45 sure that the callback uses a different lock for each kind of data.
     46 
     47 *access* defines what access type libcurl wants, shared or single.
     48 
     49 *clientp* is the private pointer you set with CURLSHOPT_USERDATA(3).
     50 This pointer is not used by libcurl itself.
     51 
     52 # %PROTOCOLS%
     53 
     54 # EXAMPLE
     55 
     56 ~~~c
     57 extern void mutex_lock(CURL *handle, curl_lock_data data,
     58                        curl_lock_access access, void *clientp);
     59 
     60 int main(void)
     61 {
     62   CURLSHcode sh;
     63   CURLSH *share = curl_share_init();
     64   sh = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, mutex_lock);
     65   if(sh)
     66     printf("Error: %s\n", curl_share_strerror(sh));
     67 }
     68 ~~~
     69 
     70 # %AVAILABILITY%
     71 
     72 # RETURN VALUE
     73 
     74 CURLSHE_OK (zero) means that the option was set properly, non-zero means an
     75 error occurred. See libcurl-errors(3) for the full list with
     76 descriptions.