LaKraven / LKSL

LaKraven Studios Standard Library
http://otapi.com
Other
51 stars 15 forks source link

Event Pooling - Correct behaviour when changing Pool Size #68

Closed LaKraven closed 6 years ago

LaKraven commented 9 years ago

Currently, when you specify a different Pool Size after construction, the entire Pool is reinitialized.

This is very bad, because any pending Events to be processed by the Threads within the Pool get dropped.

The correct behaviour would be as follows:

If New Size > Current Size... simply construct the new Thread and it will begin receiving Events. If New Size < Current Size... nominate lowest performing Thread, instruct it to no longer accept Events, allow it to cycle until its Queue and Stack are empty, then destroy it (adjusting the Pool accordingly).