public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Jason Nye <jnye@nbnet.nb.ca>
To: Ross Johnson <rpj@ise.canberra.edu.au>
Cc: 'Pthreads-win32' <pthreads-win32@sourceware.cygnus.com>
Subject: Re: asynchronous cancellation
Date: Tue, 16 Nov 1999 13:11:00 -0000	[thread overview]
Message-ID: <3831C528.6635C2F9@nbnet.nb.ca> (raw)
In-Reply-To: <Pine.LNX.4.05.9911161227510.20486-100000@swan.canberra.edu.au>

John Bossom wrote:

> > Interesting solution...
> >
> > To work with the pthreads-win32 library, your AsyncCancelPoint
> > needs to get pSelf from dynamically declared TLS... (i.e. pthread_self,
> > or it's internal implementation).
> >
> > Just a note to C++ users: one shouldn't use the built-in pthreads
> > cancellation if they expect C++ stack unwinding to work....
> >

I'm a C++ developer, not necessarily a guru in the ways of pthreads -- I
do know some its specifications, however -- please, no flames!

Why does the stack have to be unwound when a thread is cancelled? Is
this a requirement of pthreads (I'm pretty sure this is not the case) or
is it just the way that pthreads-win32 has always implemented it and you
are sticking to this design? My ObjectThread library does not unwind the
stack when a thread is cancelled and the net result is that it has no
weird implementation-specific side effects from using exception handling
(whether SEH or C++) and there is no unnecessary performance overhead
when a thread gets cancelled -- no unwinding the stack, just executing
cleanup handlers/destructors and calling _exitthreadex().

IMHO using SEH and C++ exceptions ties pthreads-win32 to specific
compilers/languages and introduces unnecessary implementation-specific
side-effects that will catch some developers by surprise (it caught me
by surprise -- and note John's last point). Cancellation can be easily
implemented without using such constructs and the result is a
compiler-independent library in which cancellation acts as one would
expect.

Note that I'm not trying to say "Mine is better than yours", I'm just
saying that there is an another way to achieve cancellation that may be
more reliable and more compliant to the standard.

Cheerio,
Jason

  reply	other threads:[~1999-11-16 13:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-15  7:45 Bossom, John
1999-11-16  1:30 ` Ross Johnson
1999-11-16 13:11   ` Jason Nye [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-11-16 14:40 Bossom, John
1999-11-12 18:08 Jason Nye
1999-11-16 19:17 ` Ross Johnson
1999-11-17  4:46   ` Jason Nye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3831C528.6635C2F9@nbnet.nb.ca \
    --to=jnye@nbnet.nb.ca \
    --cc=pthreads-win32@sourceware.cygnus.com \
    --cc=rpj@ise.canberra.edu.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).