…iquepaz-clean_shutdown Conflicts: src/poolboy.erl
Because gen doesn't export the start_ret type, we need to move it into poolboy to actually use it.
Instead of round-robin of worker selection from the pool, we now use a LIFO principle to select a worker. Rationale behind this is that 'hot' workers are better workers to use than cold workers. For instance, in database applications, worker processes might decide to close their connection after being idle for a while (see devinus' comment on #30). Doing round-robin selection would cause a new database connection to be established each time for each new worker even when the pressure on the pool is low (e.g. with just 1 process doing sequential db queries).
WARNING: this commit breaks compatibility with Erlang releases prior to R15
Blocking/1 was added in quickcheck 1.27 and allows the test to indicate which states might block execution and lets quickcheck find bugs around them. The bug uncovered has to do with when a process holding a worker exits, the DOWN monitor fires and poolboy calls supervisor:terminate_child on the worker the process held. When the EXIT message comes in for that process, we then change the state around such that there is an additional worker. This caused a race condition if there were already checkout messages waiting in the mailbox, because the EXIT message would come in behind the checkout messages, and so even though we had just killed a worker, we'd fail checkouts because we hadn't processed the EXIT yet. The fix is to call into handle_worker_exit right after we terminate the worker, thus updating our state to reflect the actual worker count before processing any messages in the mailbox.
starting process. This is useful for use in e.g. init_per_suite/1 in Common Tests.