comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Win32. Task or CreateThread
Date: Fri, 5 Aug 2016 08:17:51 +0200
Date: 2016-08-05T08:17:51+02:00	[thread overview]
Message-ID: <no1b2r$vfr$1@gioia.aioe.org> (raw)
In-Reply-To: 1dde5cdf-f1a8-4e5d-8d7d-60c89c554f6a@googlegroups.com

On 2016-08-05 06:25, George J wrote:

> Hi All! I have a question for Gtk.Main.Routers, that i can't understand.
> I have next:
>
> type My_Record is
> record
> .......
> end record
>
> type My_Record_Access is access all My_Record;
>
> Test_Record_Access : My_Record_Access;
>
> package Cb_Request is new Gtk.Main.Router.Generic_Callback_Request(User_Data => My_Record);
>
>    task type My_Task is  -- works well
>       entry Start;
>    end My_Task;
>
>    task body My_Task is
>    begin
>       accept Start;
>
>       Cb_Request.Request(Some_Proc'Access,Test_Record_Access); -- all ok
>
>    end My_Task;
>
> But I need to send parameter to discriminant like this
> .. in some proc
> Some_Task.Start(Test_Record_Access)
>
> and decl:
>
>    task type My_Task is  -- works bad
>       entry Start(Rec_Acc:My_Record_Access);
>    end My_Task;
>
>    task body My_Task is
>    begin
>       accept Start(Rec_Acc:My_Record_Access) do
>          Cb_Request.Request(Some_Proc'Access,Rec_Acc); -- "freezed"
>       end Start;
>    end My_Task;

You have a deadlock here. The main task, that runs messages loop, 
engages the rendezvous Start with My_Task. During the rendezvous My_Task 
makes a request back which waits for main task timer callback to be 
serviced. That never happens because the main task sits in the rendezvous.

What you can do is to move the request out of the rendezvous letting the 
caller (main) task go:

    task body My_Task is
       Data : My_Record_Access;
    begin
       accept Start (Rec_Acc : My_Record_Access) do
          Data := Rec_Acc; -- Copy the parameter
       end Start; -- Let go
       Cb_Request.Request (Some_Proc'Access, Data); -- Ask back
    end My_Task;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  parent reply	other threads:[~2016-08-05  6:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-02 14:38 Win32. Task or CreateThread George J
2016-08-02 15:22 ` Dmitry A. Kazakov
2016-08-02 16:39   ` George J
2016-08-03 17:31   ` George J
2016-08-03 19:43     ` Dmitry A. Kazakov
2016-08-04  2:42       ` George J
2016-08-05  4:25   ` George J
2016-08-05  6:15     ` George J
2016-08-05  6:17     ` Dmitry A. Kazakov [this message]
2016-08-05  6:48       ` George J
2016-08-03 20:31 ` Aurele
2016-08-04  2:41   ` George J
replies disabled

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