tor_multipath_voip/src/algo_utils.h
2019-03-19 13:50:38 +01:00

32 lines
1.3 KiB
C

#pragma once
#include "algo_skel.h"
#include <glib-2.0/glib.h>
#include <glib-2.0/gmodule.h>
#include <glib-2.0/glib-object.h>
#define PACKET_BUFFER_SIZE 10
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);