🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #123

OOP and threads

#123
From: Kristoffer Persson
Date: Wed, 24 Nov 2004 09:56
27 lines
2158 bytes
Hi guys!

I came from realtime programming when I started to create Windows apps. One
app I made had a lot of threads in it and they communicated by sending
messages through PostThreadMessage. That's how things were done in the
realtime environment I was used to, but it's not very object oriented, is
it...

So, I thought I could make it more OO by turning each thread into an object,
which encapsulates the functionality. The object would communicate with its
owner in an OO fashion through properties, methods and events. The thread is
still needed though. I thought if the object created the thread internally,
the object's owner would not have to care about it.

The problem would be the object's message queue. The thread's message queue
would be the only one reading messages in its message queue, but if I don't
create a private message queue inside the object, the object's owner would
also receive messages from the thread, possibly deleting them before the
object gets a chance to read it.

So, to a few questions:

1. Am I on the right track?
2. How do I create the object's private message queue?
3. How do I place a message there from the object's private thread?

- Kristoffer -
Technical Details
Message-ID: <41a45b38$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,79c5857e3d266b45,start
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kristoffer Persson" <no@email>
Newsgroups: borland.public.cppbuilder.oodesign
Subject: OOP and threads
Date: Wed, 24 Nov 2004 10:56:02 +0100
Lines: 29
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 193.15.214.93
Message-ID: <41a45b38$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1101290296 193.15.214.93 (24 Nov 2004 01:58:16 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail