Re: ANN: threads enabled Itcl
- From: "zoro2" <wojciech@xxxxxxxxxx>
- Date: 18 Jul 2006 07:06:57 -0700
Eckhard Lehmann napisal(a):
No, I didn't do it that way, exactly because deep copies are not easily
possible. (think of objects that contain objects as attributes etc...).
Actually, they are possible.
Please read: http://wiki.tcl.tk/3881
For showing the error with your Threaded Itcl: http://wiki.tcl.tk/16156
There is an ItclObject* structure representing each Itcl object - and
this one is shared between threads. When the '-threadshared' flag is
set, there is an access command for the object created in *each*
thread's interpreter - that's all. These access commands refer to the
same ItclObject* structure (so syncrhronization is really necessary
here, see http://wiki.tcl.tk/16140 near the bottom).
I meant object's variables.
The issue is that Tcl_Obj gets shared across threads. If thread A
creates a list and it gets modified by thread B (not in my example, but
it would also hurt, probably), weird things might happen.
This is because Tcl uses thread local variables to store things.
From what I remember with ns_cache from AOLserver, Tcl_Obj cannot beObject deletion and thread exiting was indeed a tricky point and I
shared between threads. So if this is true, your code will probably fail
when exiting Tcl or deleting the object, probably in a more complex
scenario.
sometimes really racked my brain over debugging various scenarios
involving this. But finally I made it and hopefully it works forever
now ;-). Let me know if not...
It does not.
Tcl_Obj*'s are not shared as such. The ItclObject* structure is shared,
which has nothing to do with Tcl_Obj*. The only place where Tcl_Obj*
comes into play is, when the access commands are transferred via
tsv::get/tsv::set - and then they are just strings.
I started some kind of Tcl_Obj* representation for Itcl objects, but it
is rather useless at the moment. The code for this (in
generic/itcl_objtype.c) could be removed together with it's
dependencies and nothing would happen.
They are. Unless it can only work with using tsv::* instead of object
variables.
Also, how does it handle the following code:
namespace eval ::myns {}
A -threadshared ::myns::obj0
I would assume you may need to create the parent namespace in each other
thread.
As I've seen from Tcl_Create[Obj]Command(), the namespace is
automatically created if it does not exist.
The current patch has no regression tests for this case, but I just
extended the test suite with two tests - it seems to work correctly.
I believe it doesn't. That's why many extensions do Tcl_Eval(...,
"namespace eval ::namespace {}") before calling Tcl_Create*Command(). I
didn't check it, though.
.
- References:
- Re: ANN: threads enabled Itcl
- From: Eckhard Lehmann
- Re: ANN: threads enabled Itcl
- Prev by Date: Re: background fcopy and tracing a variable
- Next by Date: Re: background fcopy and tracing a variable
- Previous by thread: Re: ANN: threads enabled Itcl
- Next by thread: Re: ANN: threads enabled Itcl
- Index(es):
Relevant Pages
|