Re: Tasking and wxWidgets



"Lucretia" <lucretia9@xxxxxxxxxxx> writes:

> 2) I could also go the other way and inside the
> wx.Base.Object.Object_Type (wxObject) provide a mutex object, such
> that every call in wxAda would lock (on entry) and unlock (on exit)
> thus providing thread safety if that particular object were accessed
> via multiple tasks. The overhead of constructing/destructing a mutex
> locker object, locking/unlocking the mutex object on every call
> would be rather high and thus, would most probably slow the
> application down to a crawl (although, not tested). Use of inlining
> might make this nicer?

Not clear that inlining would help a lot here.

What would be acceptable? Using a Lock from the Booch çcomponents
(http://booch95.sourceforge.net) takes just under 20 us on a 1.5GHz
Powerbook.

with Ada.Text_IO; use Ada.Text_IO;
with BC.Support.High_Resolution_Time;
with BC.Support.Synchronization;
procedure Time_Lock is
Mutex : aliased BC.Support.Synchronization.Semaphore;
Start, Finish : BC.Support.High_Resolution_Time.Time;
use type BC.Support.High_Resolution_Time.Time;
begin
Start := BC.Support.High_Resolution_Time.Clock;
declare
L : BC.Support.Synchronization.Lock (Mutex'Access);
pragma Unreferenced (L);
begin
-- Mutex now secured and will be released on block exit (even
-- on exception)
null;
end;
Finish := BC.Support.High_Resolution_Time.Clock;
Put_Line ("took " & Duration'Image (Finish - Start));
end Time_Lock;
.