Hi,

I'm writing a webapplication with tntnet for which I need one extra thread 
running in the background. Unfortunately, the documentation does not have a 
lot to say about this sort of thing.

Can I just use the pthreads API to create a new thread, like one would usually 
do in a standalone app, or will that cause some unintended, strange 
side-effects? Is there maybe a tntnet specific way to create and deal with 
extra threads (unrelated to serving http-content).

Protecting access to shared variables is not an issue in this case. The thread 
has a single incoming message queue and will never have to access any 
variables belonging to other threads.

Graceful shutdown/restart however is an issue. This thread needs to run for 
the entire time the webapp is up and will need to do some cleanup before 
shutdown. I will need tntnet to somehow signal this thread about an imminent 
shutdown and then wait for it to finish.

Background:
I'm trying to program a simple browsergame as a basis for experimenting with 
the "everything-in-memory" web development approach.

The idea is simple:
The web application has no database or filestore, it simply stores its entire 
state in one big global object (which employs the usual methods to avoid 
problems with concurrent accesses).

All changes, additions and deletions to any of the objects managed by the 
applications are sent to a dedicated logging thread which will write them to 
disk asynchronically.

When the application restarts, it first reads and replays the entire log from 
the disk to recreate the same state it had when it was last shut down.

Of course, the logging could also be done synchronically (and for the time 
being, that's what I'm doing), but that will mean a slight performance hit, 
and since my main goal here is not to deliver a working webapp as soon as 
possible, but simply to experiment and learn, I'd like to go all the way.

        Guido

-- 
Oh my science!

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Tntnet-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tntnet-general

Reply via email to