#pragma once #include "algo_skel.h" #include #include #include #define PACKET_BUFFER_SIZE 100 typedef void (*algo_ctx_free_misc)(void*); struct algo_ctx { int ref_count; struct buffer_packet bps[PACKET_BUFFER_SIZE]; GQueue* free_buffer; // Available buffers GHashTable* used_buffer; // Buffers used for reading or writing GQueue* read_waiting; // Who wait to be notified for a read GHashTable* write_waiting; // Structure to track packets waiting to be written void* misc; // Additional structures algo_ctx_free_misc free_misc; // Fx ptr to free misc }; void mv_buffer_rtow(struct algo_ctx* app_ctx, struct evt_core_fdinfo* from, struct evt_core_fdinfo* to, struct buffer_packet* bp); void mv_buffer_wtor(struct algo_ctx* app_ctx, struct evt_core_fdinfo* fdinfo, struct buffer_packet* bp); struct buffer_packet* get_write_buffer(struct algo_ctx *app_ctx, struct evt_core_fdinfo *fdinfo); struct buffer_packet* get_read_buffer(struct algo_ctx *app_ctx, struct evt_core_fdinfo *fdinfo); void free_naive(void* app_ctx); void free_nothing(void* app_ctx); void notify_read(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx); void naive_free_simple(void* v);