in reply to Multi threading
First, get your nomenclature clean. You shouldn't mix threads and forks, and they are not the same.
If you are using threads, I recommend you use a Threads::Queue to serialize access to the log, and one log writer thread that reads from the queue and writes to the log file. This is the easiest way.
Another way would be to hope that your operating system has atomic writes and that your lines for the log file are shorter than 512 bytes or whatever the write buffer limit of your OS is. Then you shouldn't need to worry about threads mixing their write buffers as long as you unbuffer the filehandle.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Multi threading
by sandy1028 (Sexton) on Apr 06, 2009 at 07:17 UTC | |
by cdarke (Prior) on Apr 06, 2009 at 07:55 UTC | |
by sandy1028 (Sexton) on Apr 06, 2009 at 09:15 UTC | |
by shoness (Friar) on Apr 06, 2009 at 19:23 UTC | |
by sandy1028 (Sexton) on Apr 07, 2009 at 10:05 UTC |