From XE3...

On 17/12/2012 3:41 AM, Sven Barth wrote:
CheckSynchronize (in respect to entries queued by TThread.Queue; see below)

See below?

TThread.CurrentThread (or more precise: TThread.GetCurrentThread)

if the current thread (private variables) is nil then
  create an external thread object.
  if external thread list is nil then
    create an external thread list
Atomic Compare Exchange with the 'global' list. If the result is not nil,
      free the external thread list that was just created.'
add the newly created external thread object to the external thread list Set the private current thread object to be the newly created external thread object.
return private current thread object

Not sure if this is getting close on infringing on things....

TThread.GetIsSingleProcessor (I suspect it's just a "Result := FProcessorCount = 1")
Close. Checks to see if FProcessorCount is less than two (I hope it is never zero :-D ).

TThread.SpinWait

Checks to see if parameter is zero, if so, exit.
Loops parameter times, calling PAUSE instruction (for Intel compatible processors).

TThread.TerminatedSet

Empty method.

TThread.CheckThreadError

If the parameter is non-zero, raise an EThread exception.

TThread.NameThreadForDebugging (I don't think that we'll implement that, but I'm curious ;) )

If a debugger is present, raise a specific exception with pointer to a structure containing the name for the thread. http://stackoverflow.com/questions/9089973/is-this-the-correct-way-to-set-a-threads-name-in-delphi-6 mentions that Delphi uses the same exception value as visual studio.


Some further questions regarding Delphi's threading implementation:

Does CheckSynchronize walk the whole queue or just a specific amount?

Seems to be the whole queue (but I am not sure).

What does CheckSynchronize do if an exception happens in one of the queued methods?

If it is not queued, it attaches the exception object to the item, otherwise re-raises.

Does TThread.CurrentThread return something for externally created threads?

Don't quite understand the question.

Where/How is TThread.FExternalThread set?

Only when an external thread object is created.

Where/How is TThread.FProcessorCount set?

Gotten from system CPUCount variable (which is set from Windows API GetSystemInfo).

Is RemoveQueuedMethods called if the thread terminates?

RemoveQueuedEvents is called in the TThread destructor.

I hope that what I have done is helpful (and doesn't infringe on anything)...

Cheers,
Nick

_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to