master
1#ifndef HEADER_CURL_THRDQUEUE_H
2#define HEADER_CURL_THRDQUEUE_H
3/***************************************************************************
4 * _ _ ____ _
5 * Project ___| | | | _ \| |
6 * / __| | | | |_) | |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
9 *
10 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11 *
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.se/docs/copyright.html.
15 *
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 * SPDX-License-Identifier: curl
24 *
25 ***************************************************************************/
26#include "curl_setup.h"
27#include "curlx/timediff.h"
29struct curl_thrdq;
31#ifdef USE_THREADS
33struct Curl_easy;
35typedef enum {
36 CURL_THRDQ_EV_ITEM_DONE /* an item has been processed and is ready */
37} Curl_thrdq_event;
39/* Notification callback when "events" happen in the queue. May be called from
40 * any thread, queue is not locked. */
41typedef void Curl_thrdq_ev_cb(const struct curl_thrdq *tqueue,
42 Curl_thrdq_event ev,
43 void *user_data);
45/* Process a queued item. May be called from any thread. Queue is not
46 * locked. */
47typedef void Curl_thrdq_item_process_cb(void *item);
49/* Free an item. May be called from any thread at any time for an
50 * item that is in the queue (either before or after processing). */
51typedef void Curl_thrdq_item_free_cb(void *item);
53/* Create a new queue processing "items" by a thread pool.
54 */
55CURLcode Curl_thrdq_create(struct curl_thrdq **ptqueue,
56 const char *name,
57 uint32_t min_threads,
58 uint32_t max_threads,
59 uint32_t idle_time_ms,
60 Curl_thrdq_item_free_cb *fn_free,
61 Curl_thrdq_item_process_cb *fn_process,
62 Curl_thrdq_ev_cb *fn_event, /* optional */
63 void *user_data);
65/* Destroy the queue, free all queued items unprocessed and destroy
66 * the thread pool used.
67 * @param join TRUE when thread pool shall be joined. FALSE for
68 * detaching any running threads.
69 */
70void Curl_thrdq_destroy(struct curl_thrdq *tqueue, bool join);
72/* Send "item" onto the queue. The caller needs to clear any reference
73 * to "item" on success, e.g. the queue takes ownership.
74 * `description` is an optional string describing the item for tracing
75 * purposes. It needs to have the same lifetime as `item`.
76 *
77 * With`timeout_ms` != 0, items that get stuck that long in the send
78 * queue are removed and added to the receive queue right away.
79 */
80CURLcode Curl_thrdq_send(struct curl_thrdq *tqueue, void *item,
81 const char *description, timediff_t timeout_ms);
83/* Receive the oldest, processed item from the queue again, if there is one.
84 * The caller takes ownership of the item received, e.g. the queue
85 * relinquishes all references to item.
86 * Returns CURLE_AGAIN when there is no processed item, setting `pitem`
87 * to NULL. When nothing has been processed while items await sending,
88 * the pool is signalled to make sure a worker thread exists: an
89 * earlier thread start may have failed.
90 */
91CURLcode Curl_thrdq_recv(struct curl_thrdq *tqueue, void **pitem);
93/* Check that items awaiting processing have a worker thread to run
94 * them, signalling the pool to start one when needed -- an earlier
95 * thread start may have failed. Returns TRUE when everything is ok:
96 * no items are waiting or the pool took the signal. FALSE when a
97 * thread start just failed again; callers may want to check again
98 * soon rather than wait indefinitely.
99 */
100bool Curl_thrdq_check_started(struct curl_thrdq *tqueue);
102/* Return TRUE if the passed "item" matches. */
103typedef bool Curl_thrdq_item_match_cb(void *item, void *match_data);
105/* Clear all scheduled/processed items that match from the queue. This
106 * will *not* be able to clear items that are being processed.
107 */
108void Curl_thrdq_clear(struct curl_thrdq *tqueue,
109 Curl_thrdq_item_match_cb *fn_match,
110 void *match_data);
112CURLcode Curl_thrdq_await_done(struct curl_thrdq *tqueue,
113 uint32_t timeout_ms);
115CURLcode Curl_thrdq_set_props(struct curl_thrdq *tqueue,
116 uint32_t min_threads,
117 uint32_t max_threads,
118 uint32_t idle_time_ms);
120#ifdef CURLVERBOSE
121void Curl_thrdq_trace(struct curl_thrdq *tqueue,
122 struct Curl_easy *data);
123#define CURL_THRDQ_TRACE(t, d) \
124 do { \
125 if(Curl_trc_ft_is_verbose(d, &Curl_trc_feat_threads)) \
126 Curl_thrdq_trace(t, d); \
127 } while(0)
128#else
129#define CURL_THRDQ_TRACE(t, d) Curl_nop_stmt
130#endif
132#endif /* USE_THREADS */
134#endif /* HEADER_CURL_THRDQUEUE_H */
Diagnostics4 git calls · 31 ms
CallStatusSizeTime031 ms
discover200152 B3 ms
git.upload-pack discover http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=3 git.response.bytes=152 git.server.agent=gitty/1.0 git.server.object_format=sha1 git.server.caps=agent ls-refs fetch object-format git.server.fetch=shallow filter sideband-all git.protocol.version=2 git.pkt.frames=8 git.pkt.data=6 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=152 git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=3 git.response.bytes=149 git.response.cache=HIT git.response.duration_ms=3 git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=149 git.pkt.payload.max=78 git.ls_refs.count=2 git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=25 git.response.bytes=293470 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=blob:none git.fetch.filter.requested=tree:0 git.fetch.filter.fallback=blob:none git.fetch.filter.learned=false git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d git.fetch.haves.count=0 git.fetch.deepen=10 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=10 git.pkt.data=8 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=293470 git.pkt.payload.max=65516 git.sideband.band1.bytes=293354 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=87 git.pack.bytes=293354 git.pack.ofs_delta=0 git.pack.ref_delta=1 git.pack.chain.max=1 git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0 git.pack.full=86Open pack map
fetch2002.0 KiB · hit25 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2029 git.response.cache=HIT git.response.duration_ms=25 git.fetch.wants=ebd0c07855532bba9a6871c7efcc1dfa5ed360f3 git.fetch.haves.count=0 git.fetch.deepen=0 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=3 git.pkt.data=2 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=2029 git.pkt.payload.max=2008 git.sideband.band1.bytes=2007 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0
Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.
- Remote
- https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
- Ref
- refs/heads/master
- Commit
- 31c911efe5652725e930f4d2e60c9060e5f6646d
- cf-ray
- a5e1b2544b9af54b
- Request
- f1f147d6…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format