50 lines
1.6 KiB
C
50 lines
1.6 KiB
C
#ifndef EXECUTOR_H
|
|
#define EXECUTOR_H
|
|
|
|
#include <stdbool.h>
|
|
#include <pthread.h>
|
|
#include "fill_handler.h"
|
|
#include "config.h"
|
|
#include "slot.h"
|
|
#include "ws_client.h"
|
|
|
|
#define MAX_IN_FLIGHT 8
|
|
#define MAX_TRACKED_TRIANGLES 2048
|
|
|
|
/* Shared in-flight state across all executor threads (protected by lock). */
|
|
typedef struct {
|
|
pthread_mutex_t lock;
|
|
char triangles[MAX_IN_FLIGHT][128];
|
|
uint64_t pairs[MAX_IN_FLIGHT];
|
|
char primary_quotes[MAX_IN_FLIGHT][16];
|
|
int count;
|
|
char last_triangles[MAX_TRACKED_TRIANGLES][128];
|
|
int64_t last_book_ts[MAX_TRACKED_TRIANGLES];
|
|
int last_count;
|
|
} executor_shared_t;
|
|
|
|
/* Per-thread data for the executor. */
|
|
typedef struct executor_thread_s executor_thread_t;
|
|
|
|
/* Create an executor thread (one per concurrent slot). */
|
|
executor_thread_t *executor_thread_create(const config_t *cfg,
|
|
fill_channel_t *fill_ch,
|
|
ws_client_t *ws,
|
|
executor_shared_t *shared,
|
|
executor_slot_t *slot);
|
|
|
|
/* Execute a single triangle signal (blocking, called from executor thread). */
|
|
void executor_execute_triangle(executor_thread_t *et,
|
|
signal_entry_t *sig);
|
|
|
|
/* Report status text. */
|
|
void executor_write_report(const char *fmt, ...);
|
|
|
|
/* Warm up the authenticated REST connection (keepalive). Returns true on success. */
|
|
bool executor_keepalive(executor_thread_t *et);
|
|
|
|
/* Destroy and free. */
|
|
void executor_thread_destroy(executor_thread_t *et);
|
|
|
|
#endif
|