summaryrefslogtreecommitdiff
path: root/src/System.Private.CoreLib/shared/System/Threading
AgeCommit message (Collapse)AuthorFilesLines
2020-02-18Fix AppDomain.SetPrincipalPolicy bug for new threads (#32104) (#28019)Eirik Tsarpalis1-3/+4
* fix principal policy for new threads Fixes #31717 Co-authored-by: Marco Rossignoli <marco.rossignoli@gmail.com>
2020-01-14Fix CancellationTokenRegistration.Unregister race condition (#27949)Stephen Toub1-1/+9
2019-07-28Fix nullability annotations for static (#25914)Stephen Toub1-3/+3
The compiler is now analyzing statics. Get compliant.
2019-07-18Make all event types nullable (#25752)Stephen Toub1-1/+1
Late-breaking design change: all events should be declared with nullable delegate types.
2019-07-18Remove now unnecessary !s / TODO-NULLABLE comments (#25749)Stephen Toub8-81/+81
* Remove !s and TODO-NULLABLE comments for [DoesNotReturn] * Remove !s and TODO-NULLABLE comments for [NotNullIfNotNull] * Remove !s and TODO-NULLABLE comments for writes via Interlocked.CompareExchange * Remove !s and TODO-NULLABLE comments for Debug.Assert on fields * Update/add several TODO-NULLABLE comments
2019-07-16Disable debugger evaluation of ValueTask<T>.Result (#25727)Stephen Toub1-0/+3
If the debugger evaluates a `ValueTask<T>`'s `Result`, that counts as the "you should only consume a `ValueTask<T>`" once, and ends up breaking / hanging / throwing exceptions and other bad stuff while stepping through code in the debugger. This commit addresses that in two ways: 1. Adds `[DebuggerBrowsable(Never)]` to `Result` to prevent it from showing up in debugger views. 2. Adds a NotifyOfCrossThreadDependency call to its ToString. This prevents the debugger from using ToString to show an implicit representation of the instance, and it forces the developer explicitly trying to access ToString (e.g. in the watch window) to click a button acknowleding the impact. (Post 3.0, we should consider removing the `ValueTask<T>.ToString()` override altogether.)
2019-07-11Fix build break in TimerQueue.Portable.csJan Kotas1-5/+5
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
2019-07-11Remove stale nullable !s and pragmas (#25640)Stephen Toub8-11/+11
Also update TODO-NULLABLE comments to be more specific where appropriate.
2019-07-09Fix Timer argument exception parameter names (#25617)Stephen Toub1-5/+5
2019-07-09Fix regression in Timers with long timeouts (#25604)Stephen Toub3-25/+20
* Fix regression in Timers with long timeouts Early in .NET Core 3.0, we added an important optimization to significantly reduce lock contention and CPU overheads in situations where lots of timers were firing. The optimization worked by splitting the set of timers into those expected to fire in the very near future and then everything else. However, for really long timers (e.g. > 24 days), due to integer overflows we can accidentally put a long timer onto the short list and cause a timer that shouldn’t fire for days to instead fire in milliseconds. This is not the first such bug we’ve had in Timer, and there is a fair amount of complicated casting (that we sometimes get wrong, obviously) in order to keep the tick count usage within the Int32 domain. This PR addresses the problem (and hopefully others in the future) by switching over to using Int64. We’re already paying to get 64-bit tick counts on both Windows and Unix, so this just removes truncation that was being performed, does a little more addition/comparison with 64-bit values instead of with 32-bit, and stores an Int64 instead of Int32 in each TimerQueueTimer. On 64-bit, this has a 0 increase in memory consumption, as it simply ends up utilizing padding space that was previously in TimerQueueTimer. On 32-bit, it increases memory allocation when creating a Timer by 4 bytes from 80 to 84 (still 3 allocations), but I believe it’s the right trade-off for reduced complexity and bug likelihood. * Address PR feedback
2019-06-28Fix an assertion failure in the thread pool's QueueUserWorkItemCallbackBase ↵Koundinya Veluri1-1/+2
(#25482) Fixes https://github.com/dotnet/coreclr/issues/25242 - The issue could be that there is no memory barrier (or in the wrong place) on the thread reading the value, and an old value could be cached and read
2019-06-27React to new compiler nullability warningsSantiago Fernandez Madero1-1/+2
2019-06-26Don't show AggressiveInlining items in exception stacks (#25408)Ben Adams1-1/+0
2019-06-24Force secondary await continuations to run asynchronously (#25280)Stephen Toub1-20/+54
* Force secondary await continuations to run asynchronously For performance reasons, await continuations have been invoked synchronously, meaning they're invoked as part of the antecedent task's completion (as long as that task allows it, as long as there's sufficient stack space, etc.) This generally works out well in the case where there's a single await continuation, which is far and away the common case. However, it can cause problems in situations where there are multiple await continuations, as those continuations will end up being serialized, which can lead to slowdowns and deadlocks in niche situations. To address that, this commit backs off a bit. The first await continuation is still invoked synchronously, but subsequent await continuations are invoked asynchronously, such that they are not blocked by a previously registered await continuation. * Fix nits
2019-06-13Update Corelib to adapt to compiler nullability updatesStephen Toub5-14/+14
2019-06-12Remove defunct !s and update some TODO-NULLABLE commentsStephen Toub3-13/+5
2019-06-11Track timer count and add Timer.ActiveCount (#25061)Koundinya Veluri1-0/+25
* Track timer count and add Timer.Count Part of https://github.com/dotnet/corefx/issues/38422 * Use lock to prevent tearing * Add assert * Rename Count to ActiveCount * Fix build
2019-06-06Add [NotNull] to syncLock parameter of EnsureInitialized (#25012)Stephen Toub1-7/+7
2019-06-05Merge pull request #24937 from safern/FixNullableAnnotationsApiReviewSantiago Fernandez Madero1-1/+2
Fix some nullable annotations from API Review
2019-06-04Remove stale Task async extension methods from TaskExtensions (#24958)Santiago Fernandez Madero1-30/+0
2019-06-03PR FeedbackSantiago Fernandez Madero2-5/+1
2019-06-03Fix some nullable annotations from API ReviewSantiago Fernandez Madero2-0/+5
2019-06-03Remove unnecessary Shared<T> class from Task (#24931)Stephen Toub1-15/+2
It's just StrongBox<T>.
2019-05-28Fix nullable annotationJan Kotas1-1/+1
2019-05-28Fix superfluous delegate allocations in Unix WaitSubsystem (#7454)Jan Kotas1-3/+4
Fixes #7452 Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
2019-05-28Add and apply nullable attributes (#24679)Stephen Toub28-210/+247
* Add and apply nullable attributes * Adapt to API review decisions * Address PR feedback
2019-05-25Stop nulling out lock object in SemaphoreSlim (#24776)Stephen Toub1-21/+26
SemaphoreSlim.Dispose nulls out its lock object, and that's then used as an indication in other methods whether they should throw ObjectDisposedException. But nulling out an object used for synchronization in other methods is a bad practice, and while SemaphoreSlim.Dispose is not thread-safe to be used concurrently with other usage of the instance, it's still confusing when such usage leads to NullReferenceExceptions due to trying to lock on a null lock object. This change just changes the lock to be readonly, always set, and then whether the instance has been disposed is just a value set on that object (such that it's no larger than it used to be).
2019-05-24Update BuildTools, CoreClr to preview4-04022-01, preview6-27721-71, ↵dotnet-maestro-bot2-5/+5
respectively (master) (#24369) * Update BuildTools, CoreClr to preview4-04022-01, preview6-27721-71, respectively * Use `Nullable=enable` rather than `NullableContextOptions=enable` * Resolving new nullability warnings * PR Feedback
2019-05-21Reduce overhead of SemaphoreSlim.WaitAsync (#24687)Stephen Toub1-11/+23
This affects the case where SemaphoreSlim.WaitAsync is invoked, the operation completes asynchronously because there's no count available in the semaphore, and where a timeout and/or a cancellation token is passed to WaitAsync. In that case, we need to wait for the underlying wait task to complete, for cancellation to be requested, or for the timeout to elapse. There's currently one code path that handles this. This change improves that slightly by avoiding a defensive array copy. However, we can do much better when we get a cancelable token but no timeout, in which case we can avoid operations like Task.Delay, can register with the original cancellation token rather than a new one (which means we avoid forcing a new CancellationTokenSource's lazily-allocated partitions into existence), etc.
2019-05-09Turn on nullability for all of Corelib (#24497)Stephen Toub76-76/+0
* Enable nullable at the project level * Remove `#nullable enable` from individual files Removes `#nullable enable` from almost all .cs files in System.Private.CoreLib. I left it only in the ~30 files (out of ~1480 that had it) that are mirrored to corefx, that are built into projects by corefx that don't yet set NullableContextOptions at the project level, and that use nullable annotations; otherwise, they'd break the corefx build.
2019-05-06Port all managed product binaries to use SDK style projects (#24285)Aaron Robinson1-1/+1
Convert managed product binary to use SDK project system. - Uses Arcade for versions strings - Overrides Arcade defined output paths - should change in the future
2019-05-01Move the new ConfigureAwait/WithCancellation extension methods to a new type ↵Stephen Toub2-0/+44
(#24331) We decided after all to put these on a different type, TaskAsyncEnumerableExtensions. This commit adds the new type. We can delete the methods in the old location once corefx consumes an updated build and switches over to using the new ones.
2019-04-25Removing EventPipe file polling (EventPipeController+Timer) (#24225)José Rivero1-7/+1
* Remove file polling only, and leave the COMPlus_* functionality. * Fix bug/typo introduced with https://github.com/dotnet/coreclr/pull/21718
2019-04-23Implement APIs for some threading metrics (CoreRT) (dotnet/corert#7066)Koundinya Veluri1-4/+30
* Implement APIs for some threading metrics (CoreRT) - API review: https://github.com/dotnet/corefx/issues/35500 - May depend on https://github.com/dotnet/coreclr/pull/22754 * Use thread-locals for counting, use finalizer instead of runtime to detect thread exit * Don't let the count properties throw OOM * Remove some flushes Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
2019-04-20Update BuildTools, CoreClr to preview4-03917-01, preview5-27618-71, ↵dotnet-maestro-bot1-1/+1
respectively (master) (#24060) * Update BuildTools, CoreClr to preview4-03917-01, preview5-27618-71, respectively * Fix build errors * Disable warning with pragma and linked issue
2019-04-19Implement APIs for some threading metrics (CoreCLR) (#24113)Koundinya Veluri1-0/+53
Implement APIs for some threading metrics (CoreCLR) API review: https://github.com/dotnet/corefx/issues/35500
2019-04-15Merge remote-tracking branch 'dotnet/master' into merge-master-nullableSantiago Fernandez Madero2-25/+3
2019-04-14Fix a few internal nullable annotations and comments (#23987)Stephen Toub2-7/+8
2019-04-13Delete COMPlus_FinalizeOnShutdown (#23595)Jan Kotas2-25/+3
This compat quirk is increasingly more broken since the framework is generally not compatible with, and we have not heard anybody actually using it. Changed Environment.HasShutdownStarted to unconditionally return false. It does not make sense for it to ever return true with shutdown finalization disabled.
2019-04-12Merge pull request #23911 from safern/merge-master-nullableSantiago Fernandez Madero1-0/+41
Merge master into nullable branch
2019-04-12Nullable: System.Runtime.CompilerServices (#23886)Stephen Toub1-1/+1
2019-04-11Fix build errors due to merge conflictsSantiago Fernandez Madero1-1/+1
2019-04-11Merge remote-tracking branch 'dotnet/master' into merge-master-nullableSantiago Fernandez Madero1-0/+41
2019-04-10Move TimerQueue.TickCount Windows implementation to shared CoreLib (#23838)Filip Navara1-0/+40
2019-04-10Nullable: System (most of it) (#23774)Stephen Toub2-2/+2
* Nullable: shared\System (most of it) And some other things it touches. * Nullable: src\System (most of it) * Address PR feedback
2019-04-08Merge remote-tracking branch 'dotnet/master' into merge-master-nullableSantiago Fernandez Madero2-2/+3
2019-04-07Fix two new nullable warnings with latest compilerStephen Toub2-2/+3
2019-04-05Nullable: Array (#23746)Stephen Toub1-1/+1
2019-04-04Fix Debug.Assert in GenericDelegateCache (#23755)Santiago Fernandez Madero1-1/+1
2019-04-04Merge remote-tracking branch 'dotnet/master' into merge-master-nullableSantiago Fernandez Madero1-1/+7