On 09.05.2008, at 20:29, Vlad Seryakov wrote:

> So what you need is the ability to create "lightweight" Tcl thread  
> with
> minimum commands, but with couple "important" commands to access  
> special
> "global state" or ability to submit/retrieve data from "global state".
> Is this correct?

Yes. The lightweight state should be light (a wonder!)
in terms it is private, easily created, easily destroyed
and small in memory footprint. The closest "thing" in the
Tcl universe would be a child interp ([interp create]).

>
>
> But that "monster" thread, how do you execute in it?
> Using ns_proxy or messaging, or some other way?

Well messaging is first that comes to mind. Threading
extension already does that. The gotcha's are mostly
upvars and uplevels :-(

>
>
> I guess you create regular pthread, call Tcl_CreateInterp,
> register several command and execute your Tcl script.
> Why do you think it is not generic enough?

Well, kind of :-) It is like: I guess you go sit in the
rocket, turn on the boosters and fly to moon! Nothing
simpler that that. Unfortunately. I'm not NASA!

Our app consist of roghly 350.000 lines of Tcl code and
loads about 20+ external modules, all containing internal
state.  The command set is 500+ top-level commands and
they all depend on the internal state.

What MIGHT work is kind of this: create some numbers of
fully loaded interps, each sitting in its own thread.
A compute-farm, so to say. Then every other thread just
creates a slave interp in one of those and runs all its
scripts in his private slave in one of those parked threads
in the compute-farm, using some kind of message passing.
The slaves have all the commands aliased into the main
one. Not sure what would happen with uplevels and upvars
here (need to think) but this is roughly what I'm
contemplating about now.  So when a thread exits, its
thin-slave is just deleted completely. And created it is
also fast. Just alias all commands from the master. Not
sure about the global variables... this is still open.







-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
naviserver-devel mailing list
naviserver-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/naviserver-devel

Reply via email to