🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #13532

Re: Thread synchronisation - Question

#13532
From: Matt Heling
Date: Wed, 08 Oct 2003 15:54
49 lines
3519 bytes
Thank you very much!
I read out of your answer, that it wouldn't be any problem to create more
threads inside one component (the new component will not derive from
TWinControl but I think from TComponent (to be seen during design time
only)). I'm using BCB6 and had already spotted TQueue and TStack (derived
from TOrderedList). I hadn't realized, that they came new with BCB6 :-).
Following your hint, I'm planning to use TQueue for my purposes. Is there
any difference in "performance" (speed) of these two components (TQueue &
TStack). I could imagine, that TQueue works with InnerList->Add() and  the
Pop() method returns InnerList->Items[0], while TStack uses InnerList->Add()
too, but InnerList->Items[(InnerList->Count)-1] for Pop(). Which of them is
faster (IF one is.)? Or is there no difference at all, because TLists every
time deal with pointers only?

Best regards,

HELI



Remy Lebeau (TeamB) <gambit47.no.spam@no.spam.yahoo.com> schrieb in im
Newsbeitrag: 3f82f6cd$1@newsgroups.borland.com...
>
> "Matt Heling" <heli@_REMOVE_THIS_heling.de> wrote in message
> news:3f82de8b@newsgroups.borland.com...
>
> > I'm trying to write a component, which in one thread fetches data
> > from some hardware (measurement data), whenever data should
> > be ready to be fetched, stores the data immediately into memory
> > buffer (a kind of a Fifo) and "tells" the other thread, it would now
> > be allowed to read the data, when it would be ready to do so.
>
> That's easy to do.  Simply store the data into a TThreadList so that the
> data collecting is thread-safe, and then post a message to the main
> component whenever data is available.  TThreadList makes sure that only 1
> thread can access the data at any given time.  Or, if you're using BCB6
> only, then there is a new TQueue class that is already a FIFO container,
> just protect access to it using your own CriticalSection.  If the
component
> derives from TWinControl, then you can post the message to the component's
> Handle and intercept the message in the WndProc() method.  Otherwise, call
> AllocateHWnd() in the contructor to allocate a hidden window that you can
> post to, and be sure to call DeallocateHWnd() in the destructor when the
> window is no longer needed.
>
>
> Gambit
>
>
Technical Details
Message-ID: <3f84329c@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f704989@newsgroups.borland.com> <3f750c0d$2@newsgroups.borland.com> <3f818e8c@newsgroups.borland.com> <3f8198e0$1@newsgroups.borland.com> <3f82de8b@newsgroups.borland.com> <3f82f6cd$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,20b65b563d927a2d
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-10-08 08:56:16 PST
From: "Matt Heling" <heli@_REMOVE_THIS_heling.de>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f704989@newsgroups.borland.com> <3f750c0d$2@newsgroups.borland.com> <3f818e8c@newsgroups.borland.com> <3f8198e0$1@newsgroups.borland.com> <3f82de8b@newsgroups.borland.com> <3f82f6cd$1@newsgroups.borland.com>
Subject: Re: Thread synchronisation - Question
Date: Wed, 8 Oct 2003 17:54:30 +0200
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
NNTP-Posting-Host: 80.144.172.254
Message-ID: <3f84329c@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1065628316 80.144.172.254 (8 Oct 2003 08:51:56 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!38.144.126.75.MISMATCH!feed1.newsreader.com!newsreader.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail