Problems? Is your data what you think it is? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
can we use them with datatypes that are not shared? In my first reply, I said you can only queue scalars. I was wrong. After a fashion. The original Thread::Queue module, which is unfortunately no longer available on CPAN for some reason, was a wonderfully simple module that consisted of just the constructor and four methods: enqueue(), dequeue(), pending() and the little used but sometimes useful dequeue_nb(). The perfect example of a module that did just what it need to do to satisfy it name, and did it quietly and efficiently. With an interface so simple that you never have to look it up(*see later). It looked like this: Simple and beautiful. And it only allowed scalars to be shared. But you remember I mentioned never having to look up the docs? Well, long after I posted my first reply, I was watching a movie when I remembered that the module had been upgraded a while back and some new (mis)features were added. I did play with them once, but since I never need them, I'd forgotten about them. In addition to sprouting a bunch of unnecessary and definitively un-queue-like methods: peek(), insert() & extract(), it also gained the ability to convey references to arrays and hashes. I remember thinking this was a cute idea when I first saw it. Until I ran a few tests that is. This conveys arrays using my join/split method: This does the same thing using references: And here are a couple of comparative runs of both:
It really is hard justify why queueing array references is 10 times slower than joining and spliting them. Especially if you look at the processor usage rather than wall clock and realise that it takes 55 seconds cpu for the former and only 5 for the latter. So, after all that. Yes, you can share other datatypes, but you probably don't want to. At least I don't :) With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
In reply to Re^3: any module with streaming pipe implementation for use with threads (Correction. Sort of.)
by BrowserUk
|
|