Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-01

TThread.Suspend

8 messages · 4 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mark Morgan Lloyd

First question: is Start an accurate replacement for Resume, or can it only be used to start a thread created in the suspended state?

Second question: now that Suspend is deprecated, what should a thread do if it wants to stop processing pending a subsequent resume? Please note that I'm asking about a thread suspending itself: I'm aware of the issues that argue against external suspension (on platforms where this is possible).

I note that http://www.freepascal.org/docs-html/rtl/classes/tthread.html gives no indication that Suspend and Resume are deprecated.

The usage case is a system emulating multiple processors. If any processor other than the first recognises certain conditions it is to stop running, pending notification from the first processor that (e.g.) an interrupt has been handled.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Marco van de Voort
to Mark Morgan Lloyd

In our previous episode, Mark Morgan Lloyd said:

First question: is Start an accurate replacement for Resume,

Yes.

or can it only be used to start a thread created in the suspended state?

Yes.

Both yes, because anything but that was never fully supported with Resume in the first place.

Second question: now that Suspend is deprecated, what should a thread do if it wants to stop processing pending a subsequent resume?

Add a Tevent, and block on it. IOW nothing built-in.

I note that http://www.freepascal.org/docs-html/rtl/classes/tthread.html gives no indication that Suspend and Resume are deprecated.

I'll leave that to Michael.

Reply by email

Michael Van Canneyt
to Mark Morgan Lloyd: First question: is Start an accurate replacement for Resume, or can it only be used to…
Mark Morgan Lloyd wrote 10 lines
First question: is Start an accurate replacement for Resume, or can it only be used to start a thread created in the suspended state? Second question: now that Suspend is deprecated, what should a thread do if it wants to stop processing pending a subsequent resume? Please note that I'm asking about a thread suspending itself: I'm aware of the issues that argue against external suspension (on platforms where this is possible). I note that http://www.freepascal.org/docs-html/rtl/classes/tthread.html gives no indication that Suspend and Resume are deprecated.

Good point. I must adapt fpdoc to cater for this.

Michael.

Reply by email

Mark Morgan Lloyd
to Marco van de Voort: In our previous episode, Mark Morgan Lloyd said: Yes. Yes. Both yes, because anything but…
Marco van de Voort wrote 17 lines
In our previous episode, Mark Morgan Lloyd said: > First question: is Start an accurate replacement for Resume, Yes. > or can it > only be used to start a thread created in the suspended state? Yes. Both yes, because anything but that was never fully supported with Resume in the first place. > Second question: now that Suspend is deprecated, what should a thread do > if it wants to stop processing pending a subsequent resume? Add a Tevent, and block on it. IOW nothing built-in.

OK, noted. But as a stylistic point it seems to me that this very basic functionality has been ripped out of the RTL (Classes.TThread) and moved into the FCL (Syncobjs.TEvent) leaving no adequate substitute.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Michael Schnell
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 5 lines
OK, noted. But as a stylistic point it seems to me that this very basic functionality has been ripped out of the RTL (Classes.TThread) and moved into the FCL (Syncobjs.TEvent) leaving no adequate substitute.

IMHO "Suspend" never was a good idea instead of using a decent semaphore. Thus, vice versa, IMHO "Suspend" in fact is not an adequate alternative to TEvent ;-) .

-Michael

Reply by email

Marco van de Voort
to Mark Morgan Lloyd: OK, noted. But as a stylistic point it seems to me that this very basic functionality has…

In our previous episode, Mark Morgan Lloyd said:

Show quoted text 11 lines
> Both yes, because anything but that was never fully supported with Resume in > the first place. > >> Second question: now that Suspend is deprecated, what should a thread do >> if it wants to stop processing pending a subsequent resume? > > Add a Tevent, and block on it. IOW nothing built-in. OK, noted. But as a stylistic point it seems to me that this very basic functionality has been ripped out of the RTL (Classes.TThread) and moved into the FCL (Syncobjs.TEvent) leaving no adequate substitute.

Classes was originally FCL too. That kind of thinking of RTL vs FCL based on functional division is outdated. Now it is mostly just compiler bootstrapping. (even more so since the recent creation of rtl-* packages)

Reply by email

Mark Morgan Lloyd
to Marco van de Voort
Marco van de Voort wrote 14 lines
In our previous episode, Mark Morgan Lloyd said: >> Both yes, because anything but that was never fully supported with Resume in >> the first place. >> >>> Second question: now that Suspend is deprecated, what should a thread do >>> if it wants to stop processing pending a subsequent resume? >> Add a Tevent, and block on it. IOW nothing built-in. > OK, noted. But as a stylistic point it seems to me that this very basic > functionality has been ripped out of the RTL (Classes.TThread) and moved > into the FCL (Syncobjs.TEvent) leaving no adequate substitute. Classes was originally FCL too. That kind of thinking of RTL vs FCL based on functional division is outdated. Now it is mostly just compiler bootstrapping. (even more so since the recent creation of rtl-* packages)

Although it's still significant when it comes to documentation, particularly when ://lazarus-ccr.sourceforge.net/docs/

I'm trying to dig through things... if I recall correctly it's not possible to do something like {$if defined(TThread.Resume) } but I must admit that I'm having a hard time finding defined() at all, I think
http://www.freepascal.org/docs-html/prog/progsu29.html#x35-340001.1.29 needs a link to
http://www.freepascal.org/docs-html/prog/progsu125.html#x137-1380002.4.1 or at least needs the name if the section it's pointing at tightened up.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Michael Van Canneyt
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 28 lines
Marco van de Voort wrote: > In our previous episode, Mark Morgan Lloyd said: >>> Both yes, because anything but that was never fully supported with Resume >>> in >>> the first place. >>> >>>> Second question: now that Suspend is deprecated, what should a thread do >>>> if it wants to stop processing pending a subsequent resume? >>> Add a Tevent, and block on it. IOW nothing built-in. >> OK, noted. But as a stylistic point it seems to me that this very basic >> functionality has been ripped out of the RTL (Classes.TThread) and moved >> into the FCL (Syncobjs.TEvent) leaving no adequate substitute. > > Classes was originally FCL too. That kind of thinking of RTL vs FCL based > on > functional division is outdated. Now it is mostly just compiler > bootstrapping. (even more so since the recent creation of rtl-* packages) Although it's still significant when it comes to documentation, particularly when ://lazarus-ccr.sourceforge.net/docs/ I'm trying to dig through things... if I recall correctly it's not possible to do something like {$if defined(TThread.Resume) } but I must admit that I'm having a hard time finding defined() at all, I think http://www.freepascal.org/docs-html/prog/progsu29.html#x35-340001.1.29 needs a link to http://www.freepascal.org/docs-html/prog/progsu125.html#x137-1380002.4.1 or at least needs the name if the section it's pointing at tightened up.

A good remark.

I added such a link. Will be in 2.6.4.

Michael.

Reply by email