Files
utun2/u_async.h
T
jek 74249cbeb2 Add async queue wait functionality and enhance packet normalizer tests
- Implement queue_wait_threshold() with automatic waiter checking in ll_queue
- Add pkt_normalizer_flush() to force buffer sending
- Enhance test suite with async wait tests, fragmentation verification, and buffer flush tests
- Fix test edge cases by flushing packer buffer between subtests
- Improve test reliability with increased iteration limits and while loop processing
- Add connection module for secure UDP communication with ECC/AES-CCM cryptography
2026-01-14 15:39:41 +04:00

37 lines
1.4 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// uasync.h
// модуль асинхронных операций. добавляем сокеты и таймауты и mainloop их обслуживает.
#ifndef UASYNC_H
#define UASYNC_H
#include <sys/time.h>
#include <sys/select.h>
typedef void (*timeout_callback_t)(void* user_arg);// передаёт user_arg из uasync_set_timeout
typedef void (*socket_callback_t)(int fd, void* user_arg);// передаёт user_arg из uasync_add_socket
// user_arg полезен если нужно передать управляющую структуру. Ее можно выделить в памяти и в ней хранить всё что надо. т.е. при set_timeout передаём и получаем ее в callback-е
// Error type
typedef int err_t;
#define ERR_OK 0
#define ERR_FAIL -1
// API functions
void uasync_init(void);
void uasync_mainloop(void);// бесконечный цикл, __noreturn
// Timeouts, timebase = 0.1 mS
void* uasync_set_timeout(int timeout_tb, void* user_arg, timeout_callback_t callback);
err_t uasync_cancel_timeout(void* t_id);
// Sockets
void* uasync_add_socket(int fd, socket_callback_t read_cbk, socket_callback_t write_cbk, socket_callback_t except_cbk, void* user_arg);
err_t uasync_remove_socket(void* s_id);
// Single iteration of event loop with timeout (timebase units)
void uasync_poll(int timeout_tb);
#endif // UASYNC_H