Commit Graph

17 Commits

Author SHA1 Message Date
Mark Michelson 8760e32ae3 Add auto-increment option and accompanying test.
This allows for the threadpool to automatically grow if tasks
are pushed to it and no idle threads are currently available.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377803 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-11 16:34:00 +00:00
Mark Michelson 1310e659bd Solve the issue about the "CHANGE THIS" and "XXX CHANGE THIS XXX" taskprocessor names.
Unfortunately, this required a taskprocessor listener change that makes listener allocation
utterly silly. I'm going to change the scheme so that allocation of taskprocessor listeners
is done internally within taskprocessor code. This will make it parallel with threadpool
code, which is a good thing.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377687 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 20:14:23 +00:00
Mark Michelson 90d76a5026 Make thread state waiting a little less ugly and not possible to lock up.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377686 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 19:32:50 +00:00
Mark Michelson 957cb0742b Improve timedwaits in tests to actually behave like they should.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377654 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 15:55:56 +00:00
Mark Michelson 64deed062a Add threadpool options and accompanying test.
The only test added so far is an idle thread timeout
option. This will greatly aid threadpool users who wish
to maintain a threadpool by allowing for idle threads to
die out as necessary.

Test passes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377580 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 06:13:09 +00:00
Mark Michelson 5dd22df050 Improve shutdown procedure.
This helps tests to pass more often than before.
They are far less likely to queue extra processes
into the control taskprocessor since they are prevented
once the threadpool begins to shut down.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377578 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-10 05:25:38 +00:00
Mark Michelson b6a73bb451 Add some useful debugging in threadpool test failure conditions.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377475 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-09 19:06:35 +00:00
Mark Michelson 293b18ecce Create longer thread destruction test.
This one involves shrinking the threadpool in such
a way that both idle and active threads are affected.

This test made me re-realize why the zombie state exists,
so I re-added it. We don't want to clog up the control
taskprocessor by waiting on active threads to complete
what they are doing. Instead, we mark them as zombies so
that when they are done, they can clean themselves up
properly.

Without the zombie state available, the new test actually
will deadlock.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377474 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-09 18:56:25 +00:00
Mark Michelson 4deecdef72 Add a task distribution test.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377418 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-08 00:22:33 +00:00
Mark Michelson b353c80dc0 Add threadpool reactivation test.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377400 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 23:42:42 +00:00
Mark Michelson afdbd80bc3 Add a single-thread multi-task test.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377397 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 22:35:11 +00:00
Mark Michelson d9f4952b8a Add test where we create a thread and push a task.
Passes!



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377380 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 19:50:38 +00:00
Mark Michelson 2dc89eb485 Add test where we add a task then create a thread for it.
It passes.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377379 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 19:34:11 +00:00
Mark Michelson f275c11e78 Add threadpool destruction test.
It worked on the first try. Fun time.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377378 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 19:16:28 +00:00
Mark Michelson ec29862a92 Fix up categories of threadpool tests.
git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377369 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 01:03:49 +00:00
Mark Michelson 4590bfd93d Add new threadpool test and fix some taskprocessor bugs.
The new thread creation test fails because Asterisk locks up
while trying to lock a taskprocessor.

While trying to debug that, I found a race condition during taskprocessor
creation where a default taskprocessor listener could try to operate on
a partially started taskprocessor. This was fixed by adding a new callback
to taskprocessor listeners.

Then while testing that change, I found some bugs in the taskprocessor
tests where I was not properly unlocking when done with a lock. Scoped
locks have spoiled me a bit.

I still have not figured out why the threadpool thread creation test
is locking up.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377368 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-07 00:30:35 +00:00
Mark Michelson c32634e0dd Add initial simple threadpool test.
This one simply pushes a task into the threadpool and ensures
that the listener gets the callbacks expected.

It currently crashes, so I need to figure out what's wrong.



git-svn-id: https://origsvn.digium.com/svn/asterisk/team/mmichelson/threadpool@377351 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2012-12-06 20:25:17 +00:00