# Threads and Polling

> UCall for C

UCall creates no threads.
Each loop has one application polling owner, and endpoint callbacks execute synchronously on that caller.
Each batch endpoint has one polling owner, and its callbacks execute on the thread calling `ucall_server_take_batch()` or `ucall_server_take_batches()` with the handle its registration returned.
A deadline cannot preempt a callback.
One owner at a time may submit, poll, or free a client, on any thread.
CPU classes select compiled string, cryptographic, and atomic kernels once, at initialization, under the requested class or the initialization thread's capabilities.
The application keeps those threads on CPUs supporting the selected class; `serial` is the conservative choice for differing capabilities.
Server shutdown uses baseline atomics and native wakeups, so another thread can stop it without entering CPU-specific code.

`#include <ucall/types.h>`

## ucall_cpu_class_t

A CPU kernel bundle, named with the same native classes as the sibling libraries.

```c
enum ucall_cpu_class_t
```

- `ucall_cpu_class_unknown_k` = `0`: No class requested: initialization picks the best class this machine runs.
- `ucall_cpu_class_serial_k`: Portable kernels with no SIMD, which every machine runs.
- `ucall_cpu_class_intel_haswell_k`: AVX2 kernels, as on Intel Haswell.
- `ucall_cpu_class_intel_skylake_k`: Adds AVX-512 kernels, as on Intel Skylake-X.
- `ucall_cpu_class_intel_icelake_k`: Adds Ice Lake's AVX-512 extensions and SHA, as on Intel Ice Lake.
- `ucall_cpu_class_intel_alder_k`: AVX2 kernels with SHA and no AVX-512, as on Intel Alder Lake.
- `ucall_cpu_class_aws_g2_k`: NEON kernels with the AES and SHA extensions, as on AWS Graviton2.
- `ucall_cpu_class_aws_g5_k`: As on AWS Graviton5, running the kernels of [`ucall_cpu_class_aws_g2_k`](#ucall_cpu_class_aws_g2_k).
- `ucall_cpu_class_monoversioned_k`: The one class a monoversioned build compiles, over every capability it targets.

Spellings: ```
char const * ucall_cpu_class_name(ucall_cpu_class_t cpu_class);
```

```
ucall_cpu_class_t ucall_cpu_class_from_name(ucall_bytes_view_t name);
```

