libxtc 0.4.0
Async concurrency for C: Tokio + Seastar + BEAM, in one library
Loading...
Searching...
No Matches
xtc_reg.h
1/*-
2 * Copyright (c) 2026, The XTC Project
3 * Use of this source code is governed by the ISC License.
4 *
5 * src/inc/xtc_reg.h
6 * Process registry: name -> xtc_pid_t lookup. M10.5.
7 *
8 * Erlang's gen_server-via-name pattern: spawn a service, register
9 * it under a stable name, and the rest of the system finds it by
10 * name rather than by passing pids around. We provide this as a
11 * per-application table guarded by a mutex; entries are
12 * registered/unregistered explicitly.
13 */
14
15#ifndef XTC_REG_H
16#define XTC_REG_H
17
18#include <stddef.h>
19
20#include "xtc.h"
21#include "xtc_proc.h"
22
23typedef struct xtc_reg xtc_reg_t;
24
25/*
26 * PUBLIC: int xtc_reg_create __P((xtc_reg_t **));
27 * PUBLIC: void xtc_reg_destroy __P((xtc_reg_t *));
28 * PUBLIC: int xtc_reg_register __P((xtc_reg_t *, const char *, xtc_pid_t));
29 * PUBLIC: int xtc_reg_unregister __P((xtc_reg_t *, const char *));
30 * PUBLIC: int xtc_reg_whereis __P((xtc_reg_t *, const char *, xtc_pid_t *));
31 * PUBLIC: int xtc_reg_count __P((const xtc_reg_t *));
32 */
33int xtc_reg_create(xtc_reg_t **out);
34void xtc_reg_destroy(xtc_reg_t *r);
35
36/* Register name -> pid. Fails with XTC_E_INVAL if name already taken. */
37int xtc_reg_register(xtc_reg_t *r, const char *name, xtc_pid_t pid);
38
39/* Remove a name. Returns XTC_E_INVAL if not registered. */
40int xtc_reg_unregister(xtc_reg_t *r, const char *name);
41
42/* Look up a pid by name. Writes to *out_pid on success. */
43int xtc_reg_whereis(xtc_reg_t *r, const char *name, xtc_pid_t *out_pid);
44
45int xtc_reg_count(const xtc_reg_t *r);
46
47#endif /* XTC_REG_H */