in reply to Re^2: passing hashes between threads
in thread passing hashes between threads
Okay. I'll put it another way. That is the way iThreads, explicitly-shared-only data model works.
In order that the programmer needn't be concerned with locking, variables declared in one thread cannot be seen, or passed directly to, other threads in the process. When you give a reference to a non-shared variable to Thread::Queue (or any other mechanism that will convey unshared data between threads), it has to make a copy of the unshared data into the shared data-space.
And when you read a reference out of a queue and and dereference it into a non-shared variable in the other thread, the copy process --- this time from the shared data-space to the thread-local data-space -- has to happen again.
The way to avoid the copying, is to declare the data you wish to share in the shared space up front. You can then access it from any thread without copying it. Though you then have to concern yourself with locking.
|
|---|