Hi!
On Tue, May 22, 2012 at 4:08 AM, Christopher Hunt
<hun...@gmail.com> wrote:
Hey there,
I'm interested in interrupting threads that have executed for too long and having them replaced with the next task.
No. But it's simple to implement in you app. Your task would just need to periodically check 'canceled' volatile boolean variable. If gets set, it should just not execute or stop executing if it already is executing.
In addition I'd like to limit the amount of memory a single queue can consume. Are these things achievable with HawtDispatch?
No. queues are unbounded linked lists. But once again your app can easily enforce a max size by creating a semaphore set to the max size. Every time you add an item to the queue, attempt to acquire the semaphore, if it can be acquired it means you've hit the max queue size and you should reject your enqueue attempt. If you on a non HawtDispatch thread, you could also block on the semaphore until it is acquired. Once the task does execute, you just have to release the semaphore.
Kind regards,
Christopher
--
Hiram Chirino
Software Fellow | FuseSource Corp.
chi...@fusesource.com | fusesource.com
skype: hiramchirino | twitter: @hiramchirino
blog: Hiram Chirino's Bit Mojo
