🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Callback mechanics

#5957
From: Andrue Cope [TeamB]
Date: Wed, 22 Jun 2005 08:09
29 lines
1943 bytes
Remy Lebeau (TeamB) wrote:

> > In what context Windows calls my callback function?
> 
> In whatever context called the API function that then called the
> callback.

I wondered about that and hence I delayed answering (then got dragged
off onto a minor problem at work).

Technically the only thing ensuring that a callback is called from
within the thread that passed it is the design of the API and the OS.
There's nothing to stop a callback pointer being passed between
threads. It's therefore more generic to say that a callback is called
in the context of whatever thread is doing the calling.

Of course it would be horrible programming design to pass a callback
between threads but the following scenario is possible:

Thread A passes a callback to a library module.
The library module stores the callback globally.
Thread B while inside the library calls the callback.
...

At this point if the callback is not threadsafe it can cause problems.
-- 
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID: <42b91cc4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <42b7fc1d$1@newsgroups.borland.com> <42b84cd0$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,bcabb6910c82b605
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Andrue Cope [TeamB]" <no.spam@not.a.valid.address>
Subject: Re: Callback mechanics
Newsgroups: borland.public.cppbuilder.nativeapi
References: <42b7fc1d$1@newsgroups.borland.com> <42b84cd0$1@newsgroups.borland.com>
Date: Wed, 22 Jun 2005 09:09:40 +0100
User-Agent: XanaNews/1.17.5.3
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
NNTP-Posting-Host: 217.207.223.34
Message-ID: <42b91cc4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1119427780 217.207.223.34 (22 Jun 2005 01:09:40 -0700)
Lines: 29
X-Authenticated-User: acope
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-out.nntp.be!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail