Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^6: [threads] Open a file in one thread and allow others to write to it

by gulden (Monk)
on Nov 16, 2009 at 13:37 UTC ( [id://807454]=note: print w/replies, xml ) Need Help??


in reply to Re^5: [threads] Open a file in one thread and allow others to write to it
in thread [threads] Open a file in one thread and allow others to write to it

«That's why I used a shared variable to coordinate »

Your lock variable coordinates the concurrency between Perl Threads, it won't sync the OS File->writes, cos each Thread is using a cloned FileHandled and you are trusting OS Synchronization.

Now I make you a question? Why are you using a lock variable, since you are using a cloned FileHandle that is not shared between threads? You are trusting the OS sync, so the use of that shared LOCK variable is useless.It only minimizes OS->File->Writes thread concurrency

«A contentious debate is always associated with a lack of valid arguments.»
  • Comment on Re^6: [threads] Open a file in one thread and allow others to write to it

Replies are listed 'Best First'.
Re^7: [threads] Open a file in one thread and allow others to write to it
by BrowserUk (Patriarch) on Nov 16, 2009 at 13:56 UTC
    Why are you using a lock variable,

    Because in the past I have (frequently) seen the situation where separate threads writing to the same file concurrently through buffered IO, would flush buffer-fulls, not lines, and so result in fragmentary interleaving.

    And in the absence of anyone with demonstrably authoratative knowledge prepared to answer such questions, I go by the empirical eveidence of what actually happens when I do things.


    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.
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://807454]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-19 22:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found