Home Projects Jobs Clientele Contact


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CPPSERV v0.0.5 released

This release features completely rewritten threading code. Instead of having the awfull mess between RequestDispatcher and RequestHandler, each keeping track of locks, connections, threads, etc. separately, we now have nicely separated Queue class, that deals with thread pooling and task distribution. Task in this case is single client connection, which gets accepted by dispatcher, wrapped into RequestHandler object, and queued into the pool for processing. As a result threading code is lot cleaner, and dispatching/request handling code became very small and simple. Also, for now thread-pool size is fixed. Perhaps it would make sense to make it configurable option, or, more likely startup parameter. One of the reasons, is that stopping threads cleanly is PITA, and I didn't find any way to make it nice. To be more specific, cancelling POSIX thread does not let me unroll the stack propperly. Thus, if I interrupt a thread running servlet->service funtion, none of the on-stack objects will be destroyed.
One of the possible ways to handle this, is to use "polite" mode
threads, and find a way to make them throw an exception when
"stop" function is called. This could be done through combination
of signal handlers and some gcc magic, but of course it wouldn't
be very portable then. And do NPTL threads have sparate PID, or
have a way to send a signal to specific thread anyways?

Another option is to explicitly do stack unwinding from CThread.onExit()
function, but that of course is just as unportable...

Still something to ponder for a while.

Authoright © Total Knowledge: 2001-2008