Hi,
I am having some design issues with the threading model in Axis2.
According to the design and the current implemented code base we need an
abstracted threading model in the axis2 core modules. But I am currently
having some doubts about defining this threading model.
The problem with using a very high level thread pool is the inablity to
control the behaviour of the thread by the creater. Example is :
In the thread pool we have a function to execute a function inside a thread:
thread_pool_execute(thread_pool_t, worker_function);
Inside the axis2_http_server, for a new request we create a worker and
ask the thread pool to excute the run function.
axis2_status_t handle_request(...)
{
axis2_http_worker_t worker;
...
axis2_thread_pool_execute(thread_pool, worker->run);
}
The problem in this approach is the caller can't control the behaviour
of the thread which excutes the "run" function. Only the thread pool has
the control of it.
So my suggestion is we can do the same thing as what we did to the
allocator. The thread_manager is just an api which contains creation,
destroying and other control mechanisms for the threads. So the above
code will look like:
axis2_status_t handle_request(...)
{
axis2_http_worker_t worker;
...
axis2_thread_t *req_thread =
AXIS2_THREAD_CREATE(env->thread_manager, worker->run, ...);
/* after the execution */
AXIS2_THREAD_CANCEL(env->thread_manager, *req_thread ....);
}
In this way the caller has much more control over the created thread as
well as we have the freedom to implment the threading model in our own
way. Only thinng required is to implement the API specified in the
axis2_thread_manager.
Pls feel free to comment.
- Sahan