Monks, I feel pretty bad. Couple of monthes ago, I worked on project, the purpose is to create some API library. I made three sets of libraries in three languages, C, Java and Perl. C and Java versions are multi-threaded, but not the Perl version.
We sort of prematurely determined that Perl does not support thread, at least not real thread. Today, I installed 5.8.0, went through the doc, and realized Perl does have thread, lock, and even cond. Can any one share some experience with me, about its functionality,
stability and performance? I should have tried it, had I known.
I especially care how well Perl thread works with OO. When you apply lock on a hash ref, it does not lock the hash itself. I am not saying this is not reasonable, but it does worry me, as Perl class is, most of the time, a hash ref, well even array ref, it is the same thing.
Of course, when you lock a hash ref, you don't want to lock the whole hash, as different threads need to access different elements of that hash at the same time. Hash is just an aggregation, elements are loosely coupled. But class is different, whatever in that "class hash", they are tight coupled (if they are loosely coupled, you have to look at the way you define your classes), you would expect that, most of the time, a lock on an object should lock the whole object, and the user of the object should not care the implementation of the class. It would be nice, if Perl does provide a predefined way to do this, instead of leaving this totally to each monk.
Also there is this fact, that Perl is not solely OO, there is no root class, like Java's "object", and thread functionality is not implemented first in the root class, and then inherited by all.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.