Recent

Author Topic: Feature idea: TTHread modification  (Read 4972 times)

kealon

  • Newbie
  • Posts: 5
Feature idea: TTHread modification
« on: May 21, 2015, 06:05:38 pm »
Hi, All

May be call of Terminate from TThread.Destroy  move to BeforeDestruction method?

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: Feature idea: TTHread modification
« Reply #1 on: May 21, 2015, 06:51:45 pm »
are you saying that the thread code has a flaw/problem/programming error?

perhaps there is a native, human language problem.

if you are requesting a feature, you should use the correct Bugtracker link over on the left of the screen.
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Feature idea: TTHread modification
« Reply #2 on: May 21, 2015, 06:59:42 pm »
actually the request is pretty clear to me he wants to move the  Terminate method call from destroy to OnBeforeDestruction method for some reason that is not clear to me. I think that hes intention is to discuss the feature but with out any details on the PROs and CONs of the change there is no way I could agree or disagree with the request it is simple insignificant.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

BitBangerUSA

  • Full Member
  • ***
  • Posts: 183
Re: Feature idea: TTHread modification
« Reply #3 on: May 21, 2015, 07:02:20 pm »
@taazz - yeah, i kind of got that. but i was trying - perhaps poorly - to prompt him for more info.
Lazarus Ver 2.2.6 FPC Ver 3.2.2
Windows 10 Pro 64-bit

kealon

  • Newbie
  • Posts: 5
Re: Feature idea: TTHread modification
« Reply #4 on: May 21, 2015, 09:06:57 pm »
this is proposal to improve
some Code
Code: [Select]
procedure TM.Execute;
begin
  repeat
    Evnt.Wait(Infinite);
    if Terminated then break;
  ...
end;
destructor TM.Destroy;
begin
  Terminate;  // -
  if Assigned(Evnt) then Evnt.SetEvent();
  inherited Destroy;
end;   
Terminated variable has False value in Destructor before call inherited destructor
I think is no good 
because the current mechanism is very ugly

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Feature idea: TTHread modification
« Reply #5 on: May 21, 2015, 09:21:29 pm »
this is proposal to improve
some Code
Code: [Select]
procedure TM.Execute;
begin
  repeat
    Evnt.Wait(Infinite);
    if Terminated then break;
  ...
end;
destructor TM.Destroy;
begin
  Terminate;  // -
  if Assigned(Evnt) then Evnt.SetEvent();
  inherited Destroy;
end;   
Terminated variable has False value in Destructor before call inherited destructor
I think is no good 
because the current mechanism is very ugly
and it is undefined after you call the inherited destructor but it makes no difference what is the value of terminated. If the execution process entered your destructor then you have to clean up after your self and continue. It is the way that threads are designed and it makes sense, the terminated will be false if the tthread is destroyed either by calling the free method or exiting the execute method and it will be true if someone set it to true to force an exit of the execute method. What do you try to monitor that makes things so ugly for you?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

kealon

  • Newbie
  • Posts: 5
Re: Feature idea: TTHread modification
« Reply #6 on: May 22, 2015, 05:35:21 am »
Quote
If the execution process entered your destructor then you have to clean up after your self and continue.

Creating in constructor, freeing in destructor  -  it's right

but it's a difficult problem in TThread, because some fields of object may be in use

I understand that the transfer would not solve the problem completely
but I think that the current implementation is the source of the problem

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: Feature idea: TTHread modification
« Reply #7 on: May 22, 2015, 08:38:40 am »
Quote
If the execution process entered your destructor then you have to clean up after your self and continue.

Creating in constructor, freeing in destructor  -  it's right

but it's a difficult problem in TThread, because some fields of object may be in use

I understand that the transfer would not solve the problem completely
but I think that the current implementation is the source of the problem
what problem?
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018