struct tevent_threadpool_job_state {
struct tevent_threadpool_job *job;
+ struct tevent_queue_entry *qe;
};
+static void tevent_threadpool_job_cleanup(struct tevent_req *req,
+ enum tevent_req_state req_state);
+static bool tevent_threadpool_job_cancel(struct tevent_req *req);
+static void tevent_threadpool_job_trigger(struct tevent_req *req,
+ void *private_data);
+
+struct tevent_req *tevent_threadpool_job_send(TALLOC_CTX *mem_ctx,
+ struct tevent_context *ev,
+ struct tevent_threadpool *pool,
+ struct tevent_threadpool_job *job)
+{
+ struct tevent_req *req;
+ struct tevent_threadpool_job_state *state;
+
+ req = tevent_req_create(mem_ctx, &state,
+ struct tevent_threadpool_job_state);
+ if (req == NULL) {
+ return NULL;
+ }
+ state->job = job;
+
+ tevent_req_set_cleanup_fn(req, tevent_threadpool_job_cleanup);
+ tevent_req_set_cancel_fn(req, tevent_threadpool_job_cancel);
+
+ state->qe = tevent_queue_add_optimize_empty(pool->job_queue, ev, req,
+ tevent_threadpool_job_trigger,
+ state);
+ if (tevent_req_nomem(state->qe, req)) {
+ return tevent_req_post(req, ev);
+ }
+
+ return req;
+}
+
static void tevent_threadpool_job_cleanup(struct tevent_req *req,
enum tevent_req_state req_state)
{
struct tevent_threadpool_job_state);
struct tevent_threadpool_job *job = state->job;
+ TALLOC_FREE(state->qe);
+
if (job == NULL) {
return;
}
job->busy.req = NULL;
}
-struct tevent_req *tevent_threadpool_job_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct tevent_threadpool *pool,
- struct tevent_threadpool_job *job)
+
+static bool tevent_threadpool_job_cancel(struct tevent_req *req)
{
- struct tevent_req *req;
- struct tevent_threadpool_job_state *state;
+ struct tevent_threadpool_job_state *state =
+ tevent_req_data(req,
+ struct tevent_threadpool_job_state);
- req = tevent_req_create(mem_ctx, &state,
- struct tevent_threadpool_job_state);
- if (req == NULL) {
- return NULL;
- }
- state->job = job;
+ TALLOC_FREE(state->qe);
- tevent_req_set_cleanup_fn(req, tevent_threadpool_job_cleanup);
+ //TODO:
+ return false;
+}
- return req;
+static void tevent_threadpool_job_trigger(struct tevent_req *req,
+ void *private_data)
+{
}
int tevent_threadpool_job_recv(struct tevent_req *req, int *perrno)