#include <error.h>
#include <errno.h>
#include <stdint.h>
-#include <pthread.h>
+#include <sys/epoll.h>
struct event_handler;
typedef int (handle_event_fn_t)(struct event_handler *);
+typedef int (work_fn_t)(void *);
struct event_handler {
int fd;
char *name;
};
-struct mutex {
- pthread_mutex_t lock;
- int line;
- char *file;
- time_t lock_time;
- char *name;
-};
-
-int register_event_handler(struct event_handler *handler);
-
-int get_child_count(void);
-int get_parent_count(void);
+int register_event_handler(struct event_handler *handler, int op);
int init_jobcontrol(int max_jobs_requested);
int poll_job_requests(int timeout);
+int notify_job_request(void);
int do_fork(void);
-int do_fork_limited(void);
int run(const char *p, char *const argv[]);
-int harvest_zombies(int pid);
+int clear_zombie(int pid);
int run_piped(const char *cmd, char *const argv[],
int *stdinfd, int *stdoutfd, int *stderrfd);
int run_piped_stream(const char *cmd, char *const argv[],
FILE **stdinf, FILE **stdoutf, FILE **stderrf);
-void _mutex_lock_acquired(struct mutex *lock, char *file, int line);
-int _mutex_lock(struct mutex *lock, char *file, int line);
-int _mutex_unlock(struct mutex *lock);
+enum {
+ WORK_PRIORITY_HIGH,
+ WORK_PRIORITY_LOW,
+ WORK_PRIORITIES_NUM,
+};
-#define mutex_lock(lock) _mutex_lock(lock, __FILE__, __LINE__)
-#define mutex_unlock(lock) _mutex_unlock(lock)
-#define mutex_lock_acquired(lock) _mutex_lock_acquired(lock, __FILE__, __LINE__)
+int queue_work(unsigned int priority, char *name,
+ int (work_fn)(void *arg), void *arg);
#endif