diff --git a/include/hammy/job.h b/include/hammy/job.h new file mode 100644 index 0000000..5ac2ec2 --- /dev/null +++ b/include/hammy/job.h @@ -0,0 +1,16 @@ +#ifndef HAMMY_JOB_H +#define HAMMY_JOB_H + +#include +#include + +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 diff --git a/include/hammy/pool.h b/include/hammy/pool.h new file mode 100644 index 0000000..a7aca10 --- /dev/null +++ b/include/hammy/pool.h @@ -0,0 +1,23 @@ +#ifndef HAMMY_POOL_H +#define HAMMY_POOL_H + +#include +#include +#include +#include + +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 diff --git a/include/hammy/worker.h b/include/hammy/worker.h new file mode 100644 index 0000000..865ffa8 --- /dev/null +++ b/include/hammy/worker.h @@ -0,0 +1,17 @@ +#ifndef HAMMY_WORKER_H +#define HAMMY_WORKER_H + +#include +#include +#include + +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