File tree Expand file tree Collapse file tree
lib/Runtime/PlatformAgnostic/Platform/Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ namespace DateTime
7777 // in case the system time wasn't updated backwards, and cache is still beyond...
7878 if (currentTime >= data.cacheSysTime && currentTime < data.cacheSysTime + INTERVAL_FOR_TICK_BACKUP )
7979 {
80- return data.cacheSysTime + INTERVAL_FOR_TICK_BACKUP - 1 ; // wait for real time
80+ return data.cacheSysTime + INTERVAL_FOR_TICK_BACKUP ; // wait for real time
8181 }
8282
8383 data.cacheSysTime = currentTime;
Original file line number Diff line number Diff line change @@ -737,20 +737,9 @@ namespace CorUnix
737737 extern " C" CPalThread *CreateCurrentThreadData ();
738738#endif // FEATURE_PAL_SXS
739739
740- inline CPalThread *GetCurrentPalThread ()
741- {
742- return reinterpret_cast <CPalThread*>(pthread_getspecific (thObjKey));
743- }
740+ CPalThread *GetCurrentPalThread (bool force = false );
744741
745- inline CPalThread *InternalGetCurrentThread ()
746- {
747- CPalThread *pThread = GetCurrentPalThread ();
748- #if defined(FEATURE_PAL_SXS)
749- if (pThread == nullptr )
750- pThread = CreateCurrentThreadData ();
751- #endif // FEATURE_PAL_SXS
752- return pThread;
753- }
742+ CPalThread *InternalGetCurrentThread ();
754743
755744/* **
756745
Original file line number Diff line number Diff line change @@ -2911,3 +2911,47 @@ bool IsAddressOnStack(ULONG_PTR address)
29112911
29122912 return false ;
29132913}
2914+
2915+ #ifndef __IOS__
2916+ // why _Thread_local ? Because it is faster(.)
2917+ // why not replace PAL to use _Thread_local instead of front caching? _Thread_local is not cross platform
2918+
2919+ // Why ULONG_PTR? keeping type for localThread `simple` may affect implementation hence the perf. positively.
2920+ THREAD_LOCAL ULONG_PTR localThread = 0 ;
2921+ CPalThread *CorUnix::GetCurrentPalThread (bool force)
2922+ {
2923+ ULONG_PTR pThread = localThread;
2924+ if (pThread == 0 )
2925+ {
2926+ pThread = (ULONG_PTR ) reinterpret_cast <CPalThread*>(pthread_getspecific (thObjKey));
2927+ #ifdef FEATURE_PAL_SXS
2928+ if (pThread == 0 && force)
2929+ {
2930+ pThread = (ULONG_PTR ) CreateCurrentThreadData ();
2931+ }
2932+ #endif
2933+ localThread = pThread;
2934+ }
2935+
2936+ return (CPalThread*)pThread;
2937+ }
2938+ #else // !__IOS__
2939+ CPalThread *CorUnix::GetCurrentPalThread (bool force)
2940+ {
2941+ CPalThread *pThread = reinterpret_cast <CPalThread*>(pthread_getspecific (thObjKey));
2942+
2943+ #ifdef FEATURE_PAL_SXS
2944+ if (pThread == nullptr && force)
2945+ {
2946+ pThread = CreateCurrentThreadData ();
2947+ }
2948+ #endif
2949+
2950+ return pThread;
2951+ }
2952+ #endif
2953+
2954+ CPalThread *CorUnix::InternalGetCurrentThread ()
2955+ {
2956+ return GetCurrentPalThread (true );
2957+ }
You can’t perform that action at this time.
0 commit comments