You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Timothee Maret <tm...@adobe.com> on 2012/07/18 10:15:04 UTC
Sling events Barrier synchronization
Hi,
I would require to execute tasks mixing parallel and sequential execution (Barrier synchronization).
As an example, we could take the following queue of tasks:
queue: -->(task1)-->(task2, task3, task4)-->(task5)-->(task6,task7)
Group of tasks = (task1, …, taskn)
Groups of tasks are executed sequentially
Tasks in a group are executed in parallel
I could achieve this by wrapping each task in a Callable, submitting them to an ExecutorService and implementing the barrier synchronization based on the Future returned by the executor.
However, I noticed the sling's ThreadPool [0] is only processing Runnable (no Callable) and thus I am wondering if there is a better way to enable this synchronization in Sling (maybe using event queues).
Otherwise, it would be easy to add the Callable support.
Regards,
Timothee.
[0] org.apache.sling.commons.threads.ThreadPool
Re: Sling events Barrier synchronization
Posted by Timothee Maret <tm...@adobe.com>.
Hi Carsten,
Thanks for your feed back.
I have opened SLING-2540 for this and attached a patch.
Regards,
Timothee.
On 7/18/12 11:54 AM, "Carsten Ziegeler" <cz...@apache.org> wrote:
>Hi,
>
>I think there is currently no better way in Sling, so I guess adding
>support for Callable to Sling's thread pool would be a good thing
>
>Regards
>Carsten
>
>2012/7/18 Timothee Maret <tm...@adobe.com>:
>> Hi,
>>
>> I would require to execute tasks mixing parallel and sequential
>>execution (Barrier synchronization).
>> As an example, we could take the following queue of tasks:
>>
>> queue: -->(task1)-->(task2, task3, task4)-->(task5)-->(task6,task7)
>>
>> Group of tasks = (task1, Š, taskn)
>> Groups of tasks are executed sequentially
>> Tasks in a group are executed in parallel
>>
>> I could achieve this by wrapping each task in a Callable, submitting
>>them to an ExecutorService and implementing the barrier synchronization
>>based on the Future returned by the executor.
>> However, I noticed the sling's ThreadPool [0] is only processing
>>Runnable (no Callable) and thus I am wondering if there is a better way
>>to enable this synchronization in Sling (maybe using event queues).
>> Otherwise, it would be easy to add the Callable support.
>>
>> Regards,
>>
>> Timothee.
>>
>> [0] org.apache.sling.commons.threads.ThreadPool
>
>
>
>--
>Carsten Ziegeler
>cziegeler@apache.org
Re: Sling events Barrier synchronization
Posted by Carsten Ziegeler <cz...@apache.org>.
Hi,
I think there is currently no better way in Sling, so I guess adding
support for Callable to Sling's thread pool would be a good thing
Regards
Carsten
2012/7/18 Timothee Maret <tm...@adobe.com>:
> Hi,
>
> I would require to execute tasks mixing parallel and sequential execution (Barrier synchronization).
> As an example, we could take the following queue of tasks:
>
> queue: -->(task1)-->(task2, task3, task4)-->(task5)-->(task6,task7)
>
> Group of tasks = (task1, …, taskn)
> Groups of tasks are executed sequentially
> Tasks in a group are executed in parallel
>
> I could achieve this by wrapping each task in a Callable, submitting them to an ExecutorService and implementing the barrier synchronization based on the Future returned by the executor.
> However, I noticed the sling's ThreadPool [0] is only processing Runnable (no Callable) and thus I am wondering if there is a better way to enable this synchronization in Sling (maybe using event queues).
> Otherwise, it would be easy to add the Callable support.
>
> Regards,
>
> Timothee.
>
> [0] org.apache.sling.commons.threads.ThreadPool
--
Carsten Ziegeler
cziegeler@apache.org