62 lines
1.6 KiB
C
62 lines
1.6 KiB
C
#ifndef SIM_CLIENT_H
|
|
#define SIM_CLIENT_H
|
|
|
|
struct client_handle {
|
|
b32 valid;
|
|
u32 idx;
|
|
u32 gen;
|
|
};
|
|
|
|
struct sim_client {
|
|
b32 valid;
|
|
struct client_handle handle;
|
|
|
|
struct host_channel_id channel_id;
|
|
u64 channel_hash;
|
|
|
|
struct sim_client *next_free;
|
|
struct sim_client *next_hash;
|
|
struct sim_client *prev_hash;
|
|
|
|
struct sim_ent_handle ent;
|
|
};
|
|
|
|
struct channel_lookup_bucket {
|
|
struct sim_client *first;
|
|
struct sim_client *last;
|
|
};
|
|
|
|
struct sim_client_store {
|
|
b32 valid;
|
|
struct arena arena;
|
|
|
|
struct channel_lookup_bucket *channel_lookup_buckets;
|
|
u64 num_channel_lookup_buckets;
|
|
|
|
struct sim_client *clients;
|
|
struct sim_client *first_free_client;
|
|
u64 clients_reserved;
|
|
};
|
|
|
|
INLINE struct sim_client *client_nil(void)
|
|
{
|
|
extern READONLY struct sim_client _g_sim_client_nil;
|
|
return &_g_sim_client_nil;
|
|
}
|
|
|
|
INLINE struct sim_client_store *client_store_nil(void)
|
|
{
|
|
extern READONLY struct sim_client_store _g_sim_client_store_nil;
|
|
return &_g_sim_client_store_nil;
|
|
}
|
|
|
|
struct sim_client_store *client_store_alloc(void);
|
|
void client_store_release(struct sim_client_store *store);
|
|
struct sim_client_store *client_store_from_client(struct sim_client *client);
|
|
struct sim_client *client_from_handle(struct sim_client_store *store, struct client_handle handle);
|
|
struct sim_client *client_from_channel_id(struct sim_client_store *store, struct host_channel_id channel_id);
|
|
struct sim_client *client_alloc(struct sim_client_store *store, struct host_channel_id channel_id);
|
|
void client_release(struct sim_client *client);
|
|
|
|
#endif
|