0.18 23 July 2002 Finally (hopefully) fixed problems with deadlocking. It seems that accessing unlocked shared arrays and hashes may cause deadlocking issues also because locks are happening at the C-level. Will investigate later. 0.17 22 July 2002 Added support for job throttling by the "maxjobs" and "minjobs" field in the "new" method. Adapted the "_random" and "_stream" dispatchers as well as the "job" method. Added test-suite for this as well. This code is really still alpha, it does not seem to get through the test always, so there could still be some deadlocking issues here. Added method "results". Returns the job IDs of which there are still results ready to be fetched. Returns the number of results in scalar context. Added class method "monitor" that returns the Thread::Queue::Any::Monitored object associated with the pool in the "do", "pre" and "post" routine if monitoring. Changed rogue DESTROY hack to use UNIVERSAL::isa(). Suggested by Ken Williams. Added the first full blown example: a simple log resolving filter. Removed some "originatingthreadid" cruft that was left behind. Also removed some "destroyed" cruft. Simplified the rogue DESTROY test hack. 0.16 21 July 2002 Added test-case for testing all of the methods that can be called. Completed the multi-thread job submission test. Changed DESTROY to only do something when in the originating thread. Found bug in 5.8.0 that is calling DESTROY just too many times. Found a way around that by using the CLONE subroutine. This fixes the segfaults that I have been seeing, that I realize now, were caused by the extra DESTROYs. 20 July 2002 Started the multi-thread job-submitter test-suite. Ran into segfaults. Trying to reproduce them in a simpler example now. 0.15 19 July 2002 Also fixed "abort" functionality in case there weren't any jobs to do anymore: the worker threads would be blocked on reading the job queue and not see the abort flag. Now, the remaining threads are signalled to stop the ordinary way. Added test-suite for "abort" functionality. Added internal routine "_first_todo_jobid" which allows "shutdown" to only stream results of jobs actually done, rather then to try to stream results that weren't created yet. This should fix the "abort" functionality. Renamed internal routine "_freeze" to "set_result" and exposed it to the world as part of the "jobid" and "dont_set_result" combo. This should now allow the development of the completely asynchronous log resolve module I was thinking about, where lookups on the same IP number will be handled by a single thread rather than by any thread that just happens to get the IP-number. Removed internal routine "_thaw": all thawing internally is done by calling Storable directly for speed, so it was dead wood. Added "jobid" and "dont_set_result" methods to allow "do" subroutines to have other threads create the result of the current thread. Adapted the _random and _stream dispatcher to honour these new methods. Simplified the "remove_me" functionality by a simple lexical flag rather than having to use the object. This now also makes it a class method. Fixed several minor pod nits. Removed some Carp cruft from the test-suite. 0.14 18 July 2002 Fixed problem with monitoring a thread that was't finished when shutdown time was encountered. Added support for the new "post" routine in Thread::Queue::Any::Monitored in "new" and "add". Needed so that e.g. file handles are closed and buffers flushed. Small performance improvement in "add" if more than one thread is added: original input parameters are only thawed once. Moved shutting down of monitoring thread from DESTROY back to "shutdown". This makes more sense. Added code to restart the monitoring thread if necessary in "add". Found one problem remaining in shutdown that caused the errors I was seeing yesterday. I guess 13 _was_ an unlucky number. Re-instated the full test-suite now. 0.13 17 July 2002 Testing on large numbers of threads and/or jobs keeps failing indeterminately. Lowered the number of tests to be able to get the module out there for testing on other machines. No longer passes the Thread::Pool object to the "do", "pre" and "post" routine. This to conform to the way Thread::Queue::Monitored works. If the object is needed, the "self" class method should be called. This change should also speed up things a bit. Added class method "self" for use within the "pre", "do", "post", "stream" or "monitor" routine. It returns the object they're working for. The same "pre" routine is now also passed to the internal "monitor" object. If you really want to have a different "pre" routine, then you can create a seperate Thread::Queue::Any::Monitored object and use a "stream" routine to fill that monitored queue. Changed the functionality of the "pre" routine to not save any of the returned values. It makes much more sense for the "pre" routine to set either lexical or global variables that would be automatically accessible to the "do" and "post" routine by virtue of the fact that they have their own memory space to play with. Adapted the test-suite accordingly. Added support for "monitor" keyword in "new" method. Allows you to specify a streaming mode in which the stream is handled by a single monitoring thread rather than by each thread themselves. Courtesy of the new Thread::Queue::Any::Monitored module. Fixed problem with warning being issued when starting the object. Caused by the originating thread id value not being set for the originating thread itself. 0.12 16 July 2002 Added method "waitfor" as a shortcut for using "job" and "result". Moved checks for originating thread to new internal method _check_originating_thread. Added method "abort" to have all the worker threads stop after they're finished with their current job. Adapted new, _random and _stream for this new feature. 0.11 15 July 2002 Bumped up version to 0.11 to be higher than Malcolm Beattie's original Thread::Pool module on CPAN. No other changes were made. 0.04 15 July 2002 Hopefully fixed problem in streaming caused by some stupid thread inertia problem. Problem was caused by the dispatcher assigning the jobid rather than the "job" method. Things could get out of sync before the dispatcher was reached. Added "join" method to allow intermediate cleanup of removed worker threads. Fixed up "shutdown" to call "join". Internally changed dispatcher system: there are now different dispatchers for streaming and random access mode. Method "done" now only counts jobs by removed threads. Job counts are now kept in local thread space and only made shared when the worker thread is removed. Gone back to not detaching threads. Detached threads cannot be waited for, which is a major PITA. 0.03 14 July 2002 Made sure that once the pool is shut down, calling method "shutdown" again will not do anything. At least not until method "add" is called. This should fix the situation where the pool is specifically shut down, and again shut down when the object is destroyed. Added method "notused" which returns the number of threads that were removed before they got a chance to do anything. Can be used to give you a heuristic of how many threads you actually need for a specific application. Added functionality for streaming results. This allows you to specify a "stream" subroutine that allows you to handle the result of the asynchronously executed "do" subroutines in the order in which the jobs were submitted (rather than in the order in which the results were obtained). Added "remove_me" functionality, which allows a "do" routine to tell its dispatcher that the worker thread should be removed. Added Perl version requirement to README and pod, per suggestion of mrbbking. Added -use threads- to Makefile.PL to cause breakage of the install process if threads are not available. Added specific check for named subroutine reference. The old Thread::Pool module from CPAN also allowed this. 0.02 13 July 2002 Added initial version of test-suite. Added initial version of the documentation. Added copyright info to pod. Name change threads::shared:: -> Thread:: caused this module to be renamed to the Thread:: namespace. Per Dan Sugalski's suggestion, the name became Thread::Pool. Dave Rolsky suggested that "hire" and "fire" were too cutesy. And I figured that "fire" could be misinterpreted as "fire up a thread" rather than retire. Therefore the following changes were made: hire -> add fire -> remove fired -> removed hired (deleted, moved functionality to "workers") I also changed "result_nb" to "result_dontwait", as that is a better description of what it does (who knows that "nb" stands for "non-blocking" and then knows what it means?). 0.01 12 July 2002 First version as threads::farm.