libxtc
0.4.0
Async concurrency for C: Tokio + Seastar + BEAM, in one library
Loading...
Searching...
No Matches
xtc_sched.h
1
/*-
2
* Copyright (c) 2026, The XTC Project
3
* @stability experimental
4
* Use of this source code is governed by the ISC License.
5
*/
6
#ifndef XTC_SCHED_H
7
#define XTC_SCHED_H
8
9
#include <stddef.h>
10
#include <stdint.h>
11
#include "xtc_loop.h"
12
13
#define XTC_SCHED_VERSION 1
14
/* Defer to the ordinary picker; lane -1 is the actual default lane. */
15
#define XTC_SCHED_DEFAULT (-2)
16
17
typedef
struct
xtc_sched_lane {
18
int32_t id;
19
uint32_t shares;
20
uint64_t runs, bypasses;
21
/* Advisory batch counts; never establish runqueue readiness. */
22
uint32_t ready, active;
23
}
xtc_sched_lane_t
;
24
25
typedef
struct
xtc_sched_view {
26
const
xtc_sched_lane_t
*lanes;
27
size_t
count;
28
}
xtc_sched_view_t
;
29
30
enum
xtc_sched_verdict {
31
XTC_SCHED_DONE, XTC_SCHED_YIELD, XTC_SCHED_PARK
32
};
33
typedef
struct
xtc_sched_run {
34
int32_t lane;
35
enum
xtc_sched_verdict verdict;
36
uint64_t units;
37
}
xtc_sched_run_t
;
38
39
typedef
struct
xtc_sched_policy {
40
uint32_t size, version;
41
uint32_t max_bypass;
42
int32_t (*select)(
const
xtc_sched_view_t
*,
void
*);
43
void (*ran)(
const
xtc_sched_run_t
*,
void
*);
44
void
*user;
45
}
xtc_sched_policy_t
;
46
47
typedef
struct
xtc_sched_stats {
48
uint32_t size, version;
49
uint64_t selections, fallbacks, invalid_choices, fairness_overrides;
50
}
xtc_sched_stats_t
;
51
52
#ifdef __cplusplus
53
extern
"C"
{
54
#endif
55
/* Copy descriptor; borrow callback/context through loop teardown. Setup only,
56
* frozen by the first run/step (even empty). NULL removes before first run.
57
* Callbacks must not block, yield, allocate, or mutate runtime state. */
58
XTC_API
int
xtc_sched_policy_set(xtc_loop_t *,
const
xtc_sched_policy_t
*);
59
/* Install loop-owned continuous batch-lane preference before first run. */
60
XTC_API
int
xtc_sched_continuous_set(xtc_loop_t *, uint32_t max_bypass);
61
/* Owner/quiescent reads only. Initialize size and version before calling. */
62
XTC_API
int
xtc_sched_get_stats(xtc_loop_t *,
xtc_sched_stats_t
*);
63
#ifdef __cplusplus
64
}
65
#endif
66
#endif
xtc_sched_lane_t
Definition
xtc_sched.h:17
xtc_sched_policy_t
Definition
xtc_sched.h:39
xtc_sched_run_t
Definition
xtc_sched.h:33
xtc_sched_stats_t
Definition
xtc_sched.h:47
xtc_sched_view_t
Definition
xtc_sched.h:25
src
inc
xtc_sched.h
Generated by
1.9.8