in reply to Re^2: how to split huge file reading into multiple threads
in thread how to split huge file reading into multiple threads
Anyways, you could open 1 filehandle for each thread, for that thread to report results back to the main thread. Pass the fileno of that filehandle to each thread at creation time. In the main thread, setup an IO::Select object to watch all the filehandles. Have the main thread open a private filehandle for the final output file, and as IO::Select reads the various data from each thread, it writes the output to the output file.
This would allow the threads to write without worrying about locking, while the main thread's select loop would actually handle the writing, and possibly sorting, the data out to file.
I don't know how it would work speedwise, as select will block if one thread reports alot of data, but this might be minimized by using large filehandle buffers.
That is what I would try first.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: how to split huge file reading into multiple threads
by BrowserUk (Patriarch) on Aug 30, 2011 at 23:08 UTC | |
by zentara (Cardinal) on Aug 31, 2011 at 11:21 UTC | |
by BrowserUk (Patriarch) on Aug 31, 2011 at 12:39 UTC | |
by zentara (Cardinal) on Aug 31, 2011 at 17:38 UTC | |
by zentara (Cardinal) on Sep 01, 2011 at 13:32 UTC | |
by BrowserUk (Patriarch) on Sep 02, 2011 at 02:21 UTC | |
|