pderop opened a new pull request, #613:
URL: https://github.com/apache/felix-dev/pull/613

   Motivation:
   
   A thread executing a DispatchExecutor queue must run its reentrant tasks 
inline (e.g. component.add(dependency) from init()). The end of run() released 
the queue before clearing the executing thread:
   
     m_scheduled.set(false);
     m_executingThread = null;
   
   Scenario: thread A, from the threadpool, finishes the queue and releases it. 
Thread B (a REMOVED event or stop(), which bypass the threadpool) then takes 
the queue over and sets itself as the executing thread. A then overwrites it 
with null. When a task running in B calls execute() again, B is no longer 
recognized as the queue owner: the task is queued instead of being run inline, 
and the component goes on (e.g. start()) before it has run.
   
   Modification:
   
   Rewrite DispatchExecutor around a counter of pending tasks: the thread which 
increments it from 0 owns the queue and runs tasks until it drops back to 0. 
The owner only clears the executing thread if no other thread has taken the 
queue over in the meantime. Task execution never throws, so the counter stays 
consistent. Unused methods are removed.
   
   Result:
   
   Reentrant tasks are always executed inline by the thread which owns the 
queue, and DispatchExecutor is much simpler.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to