Online Books:
java.net on MarkMail:
Search |
||
Per-object workqueues - is this a thing anybody needs?Posted by timboudreau on May 5, 2009 at 10:05 PM PDT
A couple of years ago, at OOPSLA '06, I think, I had a lot of fun hanging out with Jarda Tulach and Rich Unger and writing a generic library for enqueueing a batch of jobs that run against an object on a background thread.
The fun part was really getting to dig into the The basic idea is simple:
public interface QueueWorkProcessorand then just create a Dispatcher for it (Drainable is just a collection of jobs which can be emptied by type - so different things can handle different kinds of jobs - for example, in the DocBook module, there are both jobs that use ContentHandlers and jobs that use java.util.regex.Patterns - different code grabs the jobs of each type and runs them when the work is ready to be done). When you call Dispatcher.put (Target target, WorkType worktype), it gets enqueued - and put() never blocks and the work always gets completed (at least, so say my unit tests).
The question is, is this too esoteric and weird a thing to have its own project (you can already get it from NetBeans sources, after all), or is there someone out there who actually needs such a beast?
And as usual, there is the question what do you call a thing that does this? I've been calling it "workqueues" (you can find it in NetBeans sources in contrib/api.workqueues), but suggestions are welcome.»
Related Topics >>
Java Patterns Comments
Comments are listed in date ascending order (oldest first)
Submitted by n_varun on Tue, 2009-05-05 22:46.
Glad to see you are blogging again, as its been a pleasure reading them :)
Nice post..
Submitted by pblemel on Wed, 2009-05-06 18:55.
Yes it's useful, and scalable. Consider extending the interface to specify OutputType produced by the worker. Add a query to the registrar, and you can automate entire work flows. I coded up mine using a finite state machine. I didn't know that there was already a module for the worker part, or I would have used it instead of growing my own.
|
||
|
|