diff options
author | Emil Renner Berthing <esmil@mailme.dk> | 2013-08-26 21:45:47 +0200 |
---|---|---|
committer | Emil Renner Berthing <esmil@mailme.dk> | 2013-08-26 22:31:54 +0200 |
commit | 1952c197233c9b6c7411588750169a1f2eeed64a (patch) | |
tree | d2d9a1452fab2f6cc7807f930c165586c95b7b02 /include | |
parent | 72b7777c15ec2f806606cca8bff6211e4774daaa (diff) | |
download | lem-1952c197233c9b6c7411588750169a1f2eeed64a.tar.gz lem-1952c197233c9b6c7411588750169a1f2eeed64a.tar.xz lem-1952c197233c9b6c7411588750169a1f2eeed64a.zip |
pool: better API
The thread pool doesn't actually need the Lua thread,
so let the callers handle that.
Also if we don't care about the return allow the
reaper function to be NULL and automatically free
the lem_async struct when the worker is done.
Diffstat (limited to 'include')
-rw-r--r-- | include/lem.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/include/lem.h b/include/lem.h index 0e34734..5b35459 100644 --- a/include/lem.h +++ b/include/lem.h @@ -54,7 +54,6 @@ extern struct ev_loop *lem_loop; #endif struct lem_async { - lua_State *T; void (*work)(struct lem_async *a); void (*reap)(struct lem_async *a); struct lem_async *next; @@ -65,18 +64,17 @@ lua_State *lem_newthread(void); void lem_forgetthread(lua_State *T); void lem_queue(lua_State *T, int nargs); void lem_exit(int status); -void lem_async_put(struct lem_async *a); +void lem_async_run(struct lem_async *a); void lem_async_config(int delay, int min, int max); static inline void -lem_async_do(struct lem_async *a, lua_State *T, - void (*work)(struct lem_async *), - void (*reap)(struct lem_async *)) +lem_async_do(struct lem_async *a, + void (*work)(struct lem_async *a), + void (*reap)(struct lem_async *a)) { - a->T = T; a->work = work; a->reap = reap; - lem_async_put(a); + lem_async_run(a); } #endif |