Hi!
What I need to do sometimes is to be able to cache classes because their creation (in our case) might be a costly operation.
For example:
Class HeavyClass set hc [HeavyClass new] $hc whatevermethod
can be quite time consuming. What I'd like to do is to "cache" "things" created by "new" or even for:
HeavyClass hc hc whatevermethod
What would be the best way to achieve this caching?
Thanks for help. Zoran
On 22.11.2005, at 11:17, Zoran Vasiljevic wrote:
Hi!
What I need to do sometimes is to be able to cache classes because their creation (in our case) might be a costly operation.
Actually "Object naming and creaion" should be the correct subject, as I would really need to intercept the "new" and "unknown" and install custom code when somebody does:
Foo new or Foo bar
Zoran
For example:
Class HeavyClass set hc [HeavyClass new] $hc whatevermethod
can be quite time consuming. What I'd like to do is to "cache" "things" created by "new" or even for:
HeavyClass hc hc whatevermethod
What would be the best way to achieve this caching?
Thanks for help. Zoran _______________________________________________ Xotcl mailing list Xotcl@alice.wu-wien.ac.at http://alice.wu-wien.ac.at/mailman/listinfo/xotcl
Zoran, does this help? it will print
::xotcl::Class wants to create Foo ::Foo wants to create ::xotcl::__#1 ::Foo wants to create bar
You can do this also selectively for certain classes via mixins, or by defining an appropriate metaclass.
Greetings, -gustaf ----------------------------------------------------------------------------------------------------- Class instmixin add [Class new -instproc create {object args} { puts "[self] wants to create $object" next }]
Class Foo Foo new Foo bar
On 22.11.2005, at 15:08, Gustaf Neumann wrote:
Zoran, does this help? it will print
::xotcl::Class wants to create Foo ::Foo wants to create ::xotcl::__#1 ::Foo wants to create bar
You can do this also selectively for certain classes via mixins, or by defining an appropriate metaclass.
Ah, Gustaf, what would I do without you!? This works perfectly! After all those years of XOTcl'ing I should have come to that by myself... But I'm now in great stress testing our 2.0 release... so very short on time :-(
Thanks for the fast response. I will add this into our code. The reason is: we have couple of frequently used classes which take about 1 second to load/create object (lots of internal stuff being done) so I needed a simple re-use mechanism. Now I can add simple caching of generated objects per-thread which would speed-up certain operations by factors of magnitude!
Cheers Zoran