comp.lang.ada
 help / color / mirror / Atom feed
From: George J <ivanov_george@list.ru>
Subject: Re: Win32. Task or CreateThread
Date: Thu, 4 Aug 2016 23:48:59 -0700 (PDT)
Date: 2016-08-04T23:48:59-07:00	[thread overview]
Message-ID: <95a6be7b-8776-4545-ab00-735b70121dce@googlegroups.com> (raw)
In-Reply-To: <no1b2r$vfr$1@gioia.aioe.org>

пятница, 5 августа 2016 г., 9:18:05 UTC+3 пользователь Dmitry A. Kazakov написал:
> 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

Yeah!!It Works! I'll deal with the rendezvous mechanism. Thanks a lot Dmitry!


  reply	other threads:[~2016-08-05  6:48 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
2016-08-05  6:48       ` George J [this message]
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