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