add types.h
This commit is contained in:
Vendored
+2
-1
@@ -4,7 +4,8 @@
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/include"
|
||||
"${workspaceFolder}/include",
|
||||
"${workspaceFolder}/third_party"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
|
||||
+3
-2
@@ -5,13 +5,14 @@
|
||||
#include <dlibc/vector.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <hammy/types.h>
|
||||
#include <hammy/command.h>
|
||||
|
||||
typedef struct {
|
||||
struct hammy_bot_t {
|
||||
struct discord* client; // Owning reference to the client - handoff from main.c
|
||||
bool commands_registered; // A flag if commands have been registered. Avoid re-registering every reconnect.
|
||||
vector_t* commands; // vector_t of commands. Owning.
|
||||
} hammy_bot_t;
|
||||
};
|
||||
|
||||
// Alloc on heap and create
|
||||
hammy_bot_t* hammy_bot_create();
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
#define HAMMY_COMMAND_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <hammy/types.h>
|
||||
|
||||
typedef struct {
|
||||
struct hammy_command_t {
|
||||
// TODO: add shit here
|
||||
char empty;
|
||||
} hammy_command_t;
|
||||
};
|
||||
|
||||
// Creates the command on the heap, returns NULL if failed.
|
||||
hammy_command_t* hammy_command_create();
|
||||
|
||||
+3
-2
@@ -3,14 +3,15 @@
|
||||
|
||||
#include <concord/discord.h>
|
||||
#include <stdint.h>
|
||||
#include <hammy/types.h>
|
||||
|
||||
typedef struct {
|
||||
struct hammy_job_t {
|
||||
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
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#ifndef HAMMY_POOL_H
|
||||
#define HAMMY_POOL_H
|
||||
|
||||
#include <hammy/job.h>
|
||||
#include <hammy/worker.h>
|
||||
#include <hammy/types.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
struct hammy_pool_t {
|
||||
pthread_mutex_t lock;
|
||||
pthread_cond_t notEmpty;
|
||||
hammy_job_t** jobs; // ring buffer
|
||||
@@ -18,6 +17,6 @@ typedef struct {
|
||||
|
||||
hammy_worker_t* workers;
|
||||
size_t nWorkers;
|
||||
} hammy_pool_t;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef HAMMY_TYPES_H
|
||||
#define HAMMY_TYPES_H
|
||||
|
||||
typedef struct hammy_pool_t hammy_pool_t;
|
||||
typedef struct hammy_job_t hammy_job_t;
|
||||
typedef struct hammy_worker_t hammy_worker_t;
|
||||
typedef struct hammy_command_t hammy_command_t;
|
||||
typedef struct hammy_bot_t hammy_bot_t;
|
||||
|
||||
#endif
|
||||
@@ -2,16 +2,14 @@
|
||||
#define HAMMY_WORKER_H
|
||||
|
||||
#include <concord/discord.h>
|
||||
#include <hammy/job.h>
|
||||
#include <hammy/types.h>
|
||||
#include <pthread.h>
|
||||
|
||||
typedef struct hammy_pool_t; // forward declare
|
||||
|
||||
typedef struct {
|
||||
struct hammy_worker_t {
|
||||
pthread_t thread;
|
||||
struct discord* clientCopy; // Clone of the client for concord threading safety
|
||||
hammy_pool_t* pool;
|
||||
int id;
|
||||
} hammy_worker_t;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user