comp.lang.ada
 help / color / mirror / Atom feed
From: "Alejandro R. Mosteo" <alejandro@mosteo.com>
Subject: Re: Launching background job from Ada.Real_Time.Timing_Events
Date: Thu, 2 Jun 2016 23:25:51 +0200
Date: 2016-06-02T23:25:51+02:00	[thread overview]
Message-ID: <niq88b$rp2$1@dont-email.me> (raw)
In-Reply-To: <ni3jto$7bg$1@gioia.aioe.org>

On 25/05/16 09:23, Dmitry A. Kazakov wrote:
> On 24/05/2016 16:22, Alejandro R. Mosteo wrote:
>
>> I'm stuck with something not that strange, so I guess I need another
>> viewpoint on it.
>>
>> I want to trigger, in the future, a possibly long computation in the
>> background. For that I had thought of using the built-in Real_Time
>> events.
>>
>> My idea was to queue the job when the event is triggered, and to have a
>> worker thread waiting for jobs in the queue. However, I've just realized
>> that the event handler is itself a protected action, so I can't call
>> another potentially blocking enqueue from there.
>
> Neither is protected action. To enqueue anything into FIFO you need no
> locking. This is lock-free. To dequeue, provided single consumer there
> is no need to lock anything either. If there are several consumers, you
> use a protected object to dequeue only.
> 1-to-n: The dequeue is a waitable entry. Once you have got the packet
> out of the queue you process it outside any protected actions.
>
> 1-to-1: You use a reset-event implemented using protected object to wake
> up the consumer, which dequeues the packet. Reset event is
> race-condition free to query if the queue is empty and if so, to wait
> for the event.

I'm sorry but I don't follow your explanation. To make things simpler, 
let's consider only the 1-to-1 case. How's this protected used without a 
blocking operation?

Thanks.

>> Any ideas? Basically, how to trigger another task (without creating it)
>> from within a protected handler?
>
> Always by waiting for an entry. E.g. as described above.
>

  reply	other threads:[~2016-06-02 21:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 14:22 Launching background job from Ada.Real_Time.Timing_Events Alejandro R. Mosteo
2016-05-24 14:39 ` Mark Lorenzen
2016-05-24 15:06   ` Alejandro R. Mosteo
2016-05-24 22:21   ` Jeffrey R. Carter
2016-06-02 21:13     ` Alejandro R. Mosteo
2016-06-02 23:16       ` Jeffrey R. Carter
2016-05-24 23:52 ` Jeffrey R. Carter
2016-06-02 21:22   ` Alejandro R. Mosteo
2016-05-25  7:23 ` Dmitry A. Kazakov
2016-06-02 21:25   ` Alejandro R. Mosteo [this message]
2016-06-03  7:26     ` Dmitry A. Kazakov
2016-06-03 10:03       ` Alejandro R. Mosteo
2016-06-03 12:15         ` Dmitry A. Kazakov
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox