[hibernate-dev] Is there any specific reason for not removing any successful action from the action list in ActionQueue executeActions
Adam Warski
adam at warski.org
Tue Mar 31 05:53:01 EDT 2009
Hello,
> Is there any specific reason for not removing any successful action
> from the action list.
>
> private void executeActions(List list) throws HibernateException {
> for(Iterator actionIter =
> list.iterator();actionIter.hasNext();){
> execute( (Executable) actionIter .next());
> actionIter.remove();
> }
> session.getBatcher().executeBatch();
> }
>
In fact, I think that this doesn't cover all cases yet. It is possible
that a new event will be enqueued while processing other events
(through custom event listeners). So the action queue can grow.
But this can be solved easily with a FIFO queue:
private void executeActions(Queue queue) throws HibernateException {
while (!queue.empty()) {
execute(queue.remove());
}
session.getBatcher().executeBatch();
}
This would work both when events add new actions to the queue, and
when the executeActions() is called twice.
Adam
More information about the hibernate-dev
mailing list