in reply to ithreads, shared variables..

"It seems you can bless shared variables, for example, and the blessed object works fine in a thread.. "

But you don't call that "works", as what you want is to have it shared, but it does not give you that. The caveat stated in the document is precise, but I think it would be better to have some sample code with it, not just description in natural language.

As you said that you tested with 5.8.2, seems that it is not fixed in 5.8.2. Plus 5.8.2 might core dump when you detach thread, I would say not to upgrade to 5.8.2, if thread is important to you.

On the other hand, 5.8.1 thread has unreasonably large memory usage if you don't detach it, so make sure to detach your thread if you don't expect to join later.

Replies are listed 'Best First'.
Re: Re: ithreads, shared variables..
by castaway (Parson) on Dec 26, 2003 at 09:00 UTC
    Umm, either you read me wrong, or theres some misunderstanding. Objects/blessed scalars *do* work fine when shared, I can use them in more than one thread, no problem. The perldoc claims that 'bless' only blesses a thread local reference, and leaves the value in other threads, shared or not. This is plain untrue, according to my tests at least.

    Update: Oops. I didnt test enough, it seems. The bless creates an object in each thread the object is shared in, but changes to one do not reflect in the other, so I guess they're not really shared after all. </darn>

    I upgraded to 5.8.2 some time ago, while testing another thread problem, which core dumped in 5.8.1, this now works in 5.8.2. (See 5005threads -> ithreads (porting)) I hadnt used 5.8.1 much, because of the quick release of 5.8.2, and the fact that it is binary compatible with 5.8.0, unlike 5.8.1.

    C.