Skip to content

Instantly share code, notes, and snippets.

@Frityet
Created July 21, 2022 16:41
Show Gist options
  • Save Frityet/3d25f28cbf7f7dbcda2d6dd95a52bd03 to your computer and use it in GitHub Desktop.
Save Frityet/3d25f28cbf7f7dbcda2d6dd95a52bd03 to your computer and use it in GitHub Desktop.
typedef pthread_t Thread_t;
typedef void Job_f(size_t argc, void **argv);
struct Promise {
bool done;
void *data;
};
struct Job {
struct Job *next;
struct {
size_t count;
void **value;
} arguments;
size_t thread_id;
struct Promise promise;
Job_f *function;
};
struct JobQueue {
size_t count;
struct Job *jobs;
struct Job *top, *bottom;
};
struct Company {
struct {
size_t count;
Thread_t *threads;
} workers;
struct {
size_t count;
struct JobQueue *queues;
} jobs;
bool shouldrun;
Thread_t workthread;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment