R
Ralph Moritz
Hi,
I've written a little multi-threaded file monitoring program. When it
starts it creates a detached "factory" thread, which loops infinitely,
creating detached worker threads. In the main thread we enter a
"monitor" loop which scans a directory for new files at intervals and
inserts them into a queue for the factory thread to extract. The
factory thread will block if the maximum number of allowed worker
threads are already running or there is no data in the queue.
This design was chosen so that the monitor loop can continue running
even if the factory thread blocks. Some problems have appeared though:
* When I call sleep() in the main thread (monitor loop), it affects
the entire process, rather than just the main thread. How do I put
just one, specific thread to sleep?
* There appears to be a memory leak somewhere. When I run the program
with perl -w I get warnings about leaked scalars. How do I track
this down?
My program is included below in it's entirety. Any advice on the
design and the code will be much appreciated.
TIA,
Ralph
I've written a little multi-threaded file monitoring program. When it
starts it creates a detached "factory" thread, which loops infinitely,
creating detached worker threads. In the main thread we enter a
"monitor" loop which scans a directory for new files at intervals and
inserts them into a queue for the factory thread to extract. The
factory thread will block if the maximum number of allowed worker
threads are already running or there is no data in the queue.
This design was chosen so that the monitor loop can continue running
even if the factory thread blocks. Some problems have appeared though:
* When I call sleep() in the main thread (monitor loop), it affects
the entire process, rather than just the main thread. How do I put
just one, specific thread to sleep?
* There appears to be a memory leak somewhere. When I run the program
with perl -w I get warnings about leaked scalars. How do I track
this down?
My program is included below in it's entirety. Any advice on the
design and the code will be much appreciated.
TIA,
Ralph