[fpc-pascal] getting started with threads
Jonas Maebe
jonas.maebe at elis.ugent.be
Fri Sep 18 23:19:16 CEST 2009
On 18 Sep 2009, at 23:04, Dariusz Mazur wrote:
> But is this optimal solution:
>
> procedure SysThreadSwitch;
> begin
> Sleep(0);
> end;
>
> WinThreadManager.ThreadSwitch :=@SysThreadSwitch;
>
> procedure ThreadSwitch;
> begin
> CurrentTM.ThreadSwitch;
> end;
>
> We have 2 unnecessary invoke function. Can compiler optimize this?
> Or maybe better do ThreadSwitch and SysThreadSwitch inlined.
SysThreadSwitch cannot be inlined, because it's called as a procvar.
And since you are doing a context switch anyway, the additional
overhead of a direct and an indirect call is negligible.
Jonas
More information about the fpc-pascal
mailing list