* signaling a thread to stop
@ 2002-04-14 15:38 David Eduardo Gomez Noguera
2002-04-14 14:43 ` Glynn Clements
0 siblings, 1 reply; 2+ messages in thread
From: David Eduardo Gomez Noguera @ 2002-04-14 15:38 UTC (permalink / raw)
To: linux c programming
Hello.
I am writting a gtk program that comunicates with a pen pad. when it
starts writting, it starts doing it in "real time", just as the pen
moves, there is flow of data, so a toggle button creates a thread, and
will need to stop it too.
what is the best way to do it?
i read on libc info page pthread_cancel, but didnt understand what does
it exactly do.
I think it signals the thread, then the thread must tests its value to
see if it has been "canceled" and decide upon an action (after the
thread itself was set to CANCEL_ENABLE)what to do, am i right?
the thread needs to stop comunication with the pad, so it does not keep
sending data, and then flush any remaining data when asked to stop. And
unlock a mutex.
--
ICQ: 15605359 Bicho
=^..^=
First, they ignore you. Then they laugh at you. Then they fight you.
Then you win. Mahatma Gandhi.
-------------------------------気検体の一致------------------------------------
暑さ寒さも彼岸まで。
恋にししょうなし。恋はしあんの他。
アン アン アン とっても大好き
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: signaling a thread to stop
2002-04-14 15:38 signaling a thread to stop David Eduardo Gomez Noguera
@ 2002-04-14 14:43 ` Glynn Clements
0 siblings, 0 replies; 2+ messages in thread
From: Glynn Clements @ 2002-04-14 14:43 UTC (permalink / raw)
To: David Eduardo Gomez Noguera; +Cc: linux c programming
David Eduardo Gomez Noguera wrote:
> I am writting a gtk program that comunicates with a pen pad. when it
> starts writting, it starts doing it in "real time", just as the pen
> moves, there is flow of data, so a toggle button creates a thread, and
> will need to stop it too.
>
> what is the best way to do it?
>
> i read on libc info page pthread_cancel, but didnt understand what does
> it exactly do.
> I think it signals the thread, then the thread must tests its value to
> see if it has been "canceled" and decide upon an action (after the
> thread itself was set to CANCEL_ENABLE)what to do, am i right?
Assuming that the thread has cancellation enabled (which is the
default), if the cancellation type is deferred (the default), it will
be cancelled upon the next call to any of:
pthread_join
pthread_cond_wait
pthread_cond_timedwait
pthread_testcancel
sem_wait
sigwait
OTOH, if the cancellation type is set to asynchronous, with
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS), the thread will be
terminated as soon as it receives the request.
--
Glynn Clements <glynn.clements@virgin.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-14 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-04-14 15:38 signaling a thread to stop David Eduardo Gomez Noguera
2002-04-14 14:43 ` Glynn Clements
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 NNTP newsgroup(s).