This commit is contained in:
2026-08-28 21:36:07 +02:00
parent 01741ba375
commit b72676659a
3 changed files with 56 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
#ifndef HAMMY_JOB_H
#define HAMMY_JOB_H
#include <concord/discord.h>
#include <stdint.h>
typedef struct {
char* token; // Interaction token
u64snowflake id; // Interaction ID
u64snowflake user; // Interaction User ID
char* command;
char** args; // Might be useful to parse into a struct someday? TODO
int64_t queued_at; // Staleness checks
} hammy_job_t;
#endif
+23
View File
@@ -0,0 +1,23 @@
#ifndef HAMMY_POOL_H
#define HAMMY_POOL_H
#include <hammy/job.h>
#include <hammy/worker.h>
#include <pthread.h>
#include <stdint.h>
typedef struct {
pthread_mutex_t lock;
pthread_cond_t notEmpty;
hammy_job_t** jobs; // ring buffer
size_t head;
size_t tail;
size_t count;
size_t cap;
bool shutdown;
hammy_worker_t* workers;
size_t nWorkers;
} hammy_pool_t;
#endif
+17
View File
@@ -0,0 +1,17 @@
#ifndef HAMMY_WORKER_H
#define HAMMY_WORKER_H
#include <concord/discord.h>
#include <hammy/job.h>
#include <pthread.h>
typedef struct hammy_pool_t; // forward declare
typedef struct {
pthread_t thread;
struct discord* clientCopy; // Clone of the client for concord threading safety
hammy_pool_t* pool;
int id;
} hammy_worker_t;
#endif