Notes:
- Netware had a ThreadSwitch in there, but that is not really required
- some platform were missing the setting of FTerminated to True, thus they'll now do that as well
git-svn-id: trunk@46543 -
* Add ThreadQueueLockCounter variable to
postpone call to DoneCriticlSection to the last thread
that decrements back the counter to zero.
* CommonCleanup:
Protect ThreadQueue emptying within
a Enter/Leave-CriticalSection to avoid access y other
threads at the same time.
git-svn-id: trunk@38626 -
Note: the Sender parameter of WakeMainThread will be Nil for such threads. This is Delphi compatible.
rtl/objpas/classes/classesh.inc, TThread:
+ TThreadQueueEntry: new field ThreadID so that entries with Thread = Nil can be removed
rtl/objpas/classes/classes.inc, TThread:
* InitSynchronizeEvent: setup ThreadID field
* Synchronize: use a local TThreadQueueEntry if no TThread instance was passed in
* Queue: setup ThreadID
* RemoveQueueEvents: also check for ThreadID when trying to find the current thread
git-svn-id: trunk@33863 -
rtl/objpas/classes/classes.inc:
+ new variable ExternalThreadsCleanup to keep track whether ExternalThreads list is currently cleared
* TExternalThread.Create: add the thread instance to the external thread list
* TExetrnalThread.Destroy: remove the thread instance from the external thread list (if not in system cleanup anyway)
* CommonCleanup: set ExternalThreadsCleanup to true so that the threads don't remove themselves from the list anymore
+ added test
git-svn-id: trunk@31028 -
TFPGList<CodePointer> on archs/memory models where CodePointer is different
than Pointer. On archs/memory models where CodePointer = Pointer, TCodePtrList
is simply an alias of TList and the fgl unit isn't pulled in.
* the type of FindGlobalComponentList changed to TCodePtrList and the typecasts
from TFindGlobalComponent (procvar type) to Pointer changed to CodePointer.
This fixes compilation of unit classes in the i8086 medium memory model.
git-svn-id: trunk@25357 -
Note: The only RTL where this could lead to problems is for BeOS with the old threading implementation as this does not use "BeginThread" at all (the newer implementation does).
rtl/objpas/classes/classes.inc, TThread.Destroy:
* call "CloseThread" if the thread handle is valid (mimics the logic of the Windows RTL)
rtl/win/tthread.inc, TThread.SysDestroy:
* remove the call to "CloseHandle"; this is done by "CloseThread" afterwards
git-svn-id: trunk@24313 -
rtl/objpas/classes/classes.inc, TThread.GetCurrentThread:
* instead of checking CurrentThreadVar and reading it again afterwards we read it first into Result and check this value; this way we have one read access in the normal case and one read and one write access in the worst case
git-svn-id: trunk@23706 -
Especially for the introduction of the Queue method the internal Synchronize handling was modified. Instead of handling only one event there is now a queue of events which is walked completely when CheckSynchronize is called. Each entry in the queue can carry a PRTLEvent which will be signaled when the contained method has been executed and thus Synchronize methods can still be blocking.
Exceptions inside the queued methods are either handed back to the calling method for Synchronize events or raised directly (after leaving the queue in a valid state) to the caller of CheckSynchronize.
The way platform specific adjustments can be made to TThread was changed. Instead of implementing the Constructor and Destructor directly one now implements the methods SysCreate and SysDestroy which are called from the Constructor and Destructor respectively. All RTLs were adjusted for this and should be controlled by the platform maintainers for correct compilation (Unix works).
The new method NameThreadForDebugging has two overloaded variants: one with the thread name as AnsiString and one with the thread name as UnicodeString.
By default the AnsiString variant calls the UnicodeString variant and the latter needs to be implemented. This can be changed by defining THREADNAME_IS_ANSISTRING for a platform. Then the UnicodeString variant calls the AnsiString one and the AnsiString one needs to be implemented.
Also added was a global property CPUCount for the System unit. This property returns the number of virtual cores of the system.
New methods and functions that should be implemented per platform are:
System.GetCPUCount (default returns 1)
Classes.TThread.GetSystemTimes (default zeros the struct)
Classes.TThread.NameThreadForDebugging (default does nothing)
More detailed information about the added methods will be available in the feature announcement mail.
git-svn-id: trunk@23227 -
critical section, so that it can be entered recursively just like
the one from TSimpleRWSync + test
- reverted r14593, since the reason for using TRWSync instead of
TMultiReadExclusiveWriteSynchronizer was because the former
supported recursive write locks
git-svn-id: trunk@14594 -
for the globalnamespacelock, since it seems to require recursive locking
(which TMultiReadExclusiveWriteSynchronizer does not support)
git-svn-id: trunk@14593 -