Commit Graph
35 Commits
Author SHA1 Message Date
Wes Haggard 954fb511b3 Rename AssemblyKey properties to StrongNameKeyId as part of arcade work
Commit migrated from https://github.com/dotnet/corefx/commit/7edd861bf2dd59ecdb4284e0fd291d7458198a9d
2018-10-30 15:14:01 -07:00
Stephen Toub 1cc5f8c24f Use new threading-related APIs in Channels (dotnet/corefx#33080)
- Avoid ThreadPool-related allocations via IThreadPoolWorkItem.  We already had a fairly low allocation profile on most channels, thanks to an IValueTaskSource implementation.  This extends that implementation with an IThreadPoolWorkItem implementation so that when we do need to queue to the pool (e.g. to support RunContinuationsAsynchronously, on writes on the bounded queue, etc.), we can do so without incurring additional allocation.
- Avoid ExecutionContext costs with CancellationToken.UnsafeRegister.  Minor savings when a cancelable token is provided; we don't need to flow context as all we're doing is completing another object.

Commit migrated from https://github.com/dotnet/corefx/commit/89ab1e83a7e00d869e1580151e24f01226acaf3f
2018-10-27 03:30:49 -07:00
Stephen Toub 780f9e097a Fix a few minor issues in Channels (dotnet/corefx#32916)
* Fix a few XML comments

* Rename internal Dequeue<T> to Deque<T>

Just to better conform to the typical spelling.

* Fix includes ordering in Channels project file

* Fix continuation scheduling with non-default TaskScheduler and default SyncContext

When {Unsafe}OnCompleted is called on an AsyncOperation in Channels, without ConfigureAwait(false), we look to see if there's a current non-default SynchronizationContext, and if there isn't, then a current non-default TaskScheduler.  That's stored for later when the operation is completed.  However, if as OnCompleted is being called the operation is completed, then rather than using this captured context or scheduler later, the continuation is immediately queued to the appropriate context.  When that happens, if the current SynchronizationContext was non-null but still the default (an instance of the base class), we're incorrectly ignoring whatever TaskScheduler may have been present, and end up queueing to the thread pool rather than to that scheduler.

The fix is just to ensure that, in that case, we don't pay attention to the default SynchronizationContext.  This does so and adds a test.

* Add a test with both non-default SyncContext and TaskScheduler set

Validate that, when there's both a non-default SyncContext and a non-default TaskScheduler, we prefer the SyncContext.


Commit migrated from https://github.com/dotnet/corefx/commit/207a50b7866cef71ead4ff70e7384e77a62b985a
2018-10-19 18:18:12 -04:00
Wes Haggard 6dcf8b8bfb Update the configurations properties in projects
Commit migrated from https://github.com/dotnet/corefx/commit/fea86686c620242ce7e1911418f2fba7c4d52d4d
2018-08-29 09:45:04 -07:00
Wes Haggard ec86ca55a1 Add netcoreapp2.1 build for System.Threading.Channels
Commit migrated from https://github.com/dotnet/corefx/commit/a903f8612640ad81535078f9e5ebda1c79e403b9
2018-08-29 09:39:07 -07:00
Viktor Hofer 70bffcd308 Enable netfx perf runs and promote to netstandard
Commit migrated from https://github.com/dotnet/corefx/commit/1b33f6c57bdcb4a2be715a8eaf7ec2483dc5c6c0
2018-08-23 19:55:26 +02:00
Eric Erhardt 8b6d5baf20 Change .csproj to new Configurations property
Change .sln to use the managed C# project system GUID.


Commit migrated from https://github.com/dotnet/corefx/commit/e05508a62d28f4807f85abe9cb7adf8382f792b4
2018-06-28 17:49:22 -05:00
Eric Erhardt 1df03e5bbd Rename dir files to Directory.Build
dir.props => Directory.Build.props
dir.targets => Directory.Build.targets


Commit migrated from https://github.com/dotnet/corefx/commit/204a8dbbc23bfc51d419c93f2f2ddaf50db8020f
2018-06-15 17:07:48 -05:00
Eric Erhardt 70091b9c8b Merge master into SdkProj
Commit migrated from https://github.com/dotnet/corefx/commit/ad505eb98c6a887db2d2932fec256d9e4e394169
2018-06-11 17:20:10 -05:00
Maryam Ariyan aa841d48e0 Modify corefx to use ConcurrentQueue from shared
Commit migrated from https://github.com/dotnet/corefx/commit/13e9d66f6051db2f6be532803ef3ab66807fd992
2018-05-22 09:19:22 -04:00
wtgodbe f38ceb30be Convert all .csproj files in src to SDK-style projects
Commit migrated from https://github.com/dotnet/corefx/commit/91d7e62bbf28094a2b419b87847bcd6a7658564d
2018-05-21 11:53:46 -07:00
Wes Haggard fc526e8605 Bump assembly versions for libraries with packages
Commit migrated from https://github.com/dotnet/corefx/commit/6a1b5c0aeee747a535579da7374c05b8d878fb65
2018-04-27 14:56:18 -07:00
Eric St. John 98c0015605 Update SLNs and projects to be in sync with configurations
Commit migrated from https://github.com/dotnet/corefx/commit/8ce7e620e1b5001be002598f4d10d4becdd77a49
2018-03-08 08:25:31 -08:00
Stephen Toub 29da289387 Make UnboundedChannel.ReadAsync check for cancellation first (dotnet/corefx#27822)
For consistency across implementations.

Also tweaked code to use `default` instead of `new ValueTask<bool>(false)`.

Commit migrated from https://github.com/dotnet/corefx/commit/2be66d45e0ecab5b27f08e33e0439b14b78c8550
2018-03-07 17:11:16 -05:00
Stephen Toub 01fb60df08 Fix synchronization in Channel's AsyncOperation (dotnet/corefx#27780)
The synchronization in System.Threading.Channel's AsyncOperation was messed up after the switch to ValueTask, in particular in the face of cancellation.  The key issue was that we were using two different fields to represent operation completion, which meant they weren't being updated atomically and allowed for things to get out of sync.

For example, a thread could be completing an operation and after setting Completed but before setting the s_completedSentinel, another thread could check IsCompleted, call GetResult, make the operation available for pooled reuse, another renter of it could claim it, and then the original thread could end up continuing and storing the s_completedSentinel into an object it no longer owns.  Running the perf or stress tests would cause asserts to fire sporadically.

This commit restructures AsyncOperation to avoid such issues.  Now the _continuation field is the sole source of truth as to whether the operation has completed.  This has the nice side-effect of reducing interlocked operations for the common path (e.g. using a pooled object).  It also fixes the issues that prevented us from using pooling in BoundedChannel, so the change also enables that.

Commit migrated from https://github.com/dotnet/corefx/commit/fb3b7daa44cd5e3e4a8d1ac20d3c3f1dbae8a266
2018-03-06 17:50:36 -05:00
Stephen Toub 7482b6a4b0 Expose and roll out ValueTask extensibility
This commit does several things:
- Exposes the new `ValueTask` extensibility model being added in coreclr.  The ValueTask-related files will separately be mirrored over to corefx to enable the netstandard build of System.Threading.Tasks.Extensions.
- Adapts all `Stream`-derived types to return `ValueTask` instead of `Task` from `WriteAsync`.
- Changes the new `WebSocket` `SendAsync` method to return `ValueTask` instead of `Task`, and updates the `ManagedWebSocket` implementation accordingly.  Most `SendAsync`s on `ManagedWebSocket` should now return a `ValueTask` that's either completed synchronously (no allocation) or using a pooled object.  It now uses the underlying transport's new `WriteAsync` overload that returns `ValueTask`.
- Switches more uses of `ReadAsync` and `WriteAsync` over to the new overloads, including in Process, DeflateStream, BrotliStream, File, HttpClient, SslStream, WebClient, BufferedStream, CryptoStream,
- Removed some unnecessary array clearing from various routines using ArrayPool (after the clearing was added we changed our minds and decided clearing was only necessary in very specific circumstances)
- Implements a custom `IValueTaskSource` in Socket, such that async receives and sends become allocation-free (ammortized).  `NetworkStream` then inherits this functionality, such that its new `ReadAsync` and `WriteAsync` are also allocation-free (in the unbounded channel implementations; we can subsequently add it in for bounded).
- Implements a custom `IValueTaskSource` in System.Threading.Channels, such that reading and writing are ammortized allocation-free up to one concurrent reader and writer.
- A few random things I noticed as I was going through, e.g. missing ConfigureAwait, some incorrect synchronization in tests, etc.
- Adds a ton of new tests, mainly in System.Threading.Tasks.Extensions, System.Threading.Channels, and System.Net.Sockets.


Commit migrated from https://github.com/dotnet/corefx/commit/6d1671b2cfcf130b7bc6c059bb0508073426532a
2018-03-02 09:56:25 -08:00
Tarek Mahmoud Sayed c331042d32 Fix the throwing exception from ChannelReader.ReadAsync (dotnet/corefx#27070)
Commit migrated from https://github.com/dotnet/corefx/commit/20d9824ac3f877b2a72dd6a729134e0c5fd960ee
2018-02-12 11:20:55 -08:00
Stephen Toub e5ff70defe Fix some license headers across the repo (dotnet/corefx#27039)
Commit migrated from https://github.com/dotnet/corefx/commit/7f19e761b7400521030707df2e6fac10daa36f26
2018-02-11 08:55:26 -05:00
Tarek Mahmoud Sayed 319a402480 Restore Channels ReadAsync implementation (dotnet/corefx#26934)
* Restore Channels ReadAsync implementation

* Remove AutoResetAwaiter

* Add Base class  ReadAsync test

* address the feedback


Commit migrated from https://github.com/dotnet/corefx/commit/ce0de73e21635252ceffdb140d3a56c6c19bb565
2018-02-08 17:30:56 -08:00
Stephen Toub 8fcf047787 Return canceled task from WaitToReadAsync even if data available (dotnet/corefx#26974)
Commit migrated from https://github.com/dotnet/corefx/commit/5cec1f3491e8eac76255e48274cadccd040caf81
2018-02-08 19:14:22 -05:00
Tarek Mahmoud Sayed 833f4b1311 Add stress test to System.Threading.Channels (dotnet/corefx#26655)
* Add stress test to System.Threading.Channels

* Address the feedback

* remove un-needed line

* Add more reading and writing patterns

* Add missed suggested assert

* Feedback addressing and use IsStressModeEnabled instead of  outerloop


Commit migrated from https://github.com/dotnet/corefx/commit/5bc8074a0d4b01155319b21de1bd0713cb27bbca
2018-02-05 12:39:57 -08:00
Tarek Mahmoud Sayed c44f110706 Add Debug Views to the Channel (dotnet/corefx#26795)
* Add Debug Views to the Channel

* Add Debug Attributes test


Commit migrated from https://github.com/dotnet/corefx/commit/ea356c0b48869cc8dd374cd657c5835b3625f869
2018-02-02 18:33:59 -08:00
Stephen Toub 3274d6af71 Fix BoundedChannel.DequeueItemAndPostProcess to respect _doneWriting (dotnet/corefx#26707)
It shouldn't attempt to interact with _blockedWriters/_waitingWriters if _doneWriting has been set.

Commit migrated from https://github.com/dotnet/corefx/commit/8ae3df0dddc4608b7c03cfcae26a42d4f3deebc8
2018-01-31 14:34:24 -05:00
Tarek Mahmoud Sayed 68e558d26e Remove Unbuffer Channel (dotnet/corefx#26689)
Commit migrated from https://github.com/dotnet/corefx/commit/1f8e408e7f2b0681056d1cac55b3ccc5586e8995
2018-01-30 18:09:58 -05:00
Tarek Mahmoud Sayed d6786a915c Fix some Channel issues (dotnet/corefx#26570)
* Fix some Channel issues

These issues caught during the code review of the Channel code.

* Fix reader waiter waking inside the lock

* Addressing the feedback

* tag the problematic line of code with the tracking issue

* revert BoundedChannel changes

* remove empty lines


Commit migrated from https://github.com/dotnet/corefx/commit/b8a15a768b8255096fc87dd9cb9f33cdb4a25208
2018-01-25 13:22:42 -08:00
Santiago Fernandez Madero c077e72880 Ensure build of netcoreapp vertical of CoreFx can be done without past packages (dotnet/corefx#25921)
* Add System.Drawing.Common to netcoreapp vertical

* Make System.Data.Odbc be able to build for netcoreapp vertical

* Add netcoreapp to System.Diagnostics.PerformanceCounter

* Add netcoreapp to System.Diagnostics.EventLog

* Run UpdateVSConfigurations

* Change Contains('netcoreapp') to StartsWith('netcoreapp')

* Include netcoreapp.depproj only when BuildAllConfigurations == true

* Change tests to netcoreapp from netcoreapp2.0 for vertical


Commit migrated from https://github.com/dotnet/corefx/commit/edacccb1cd6ecf7d36cd2379df8dd609ae0eb9a4
2017-12-18 17:20:36 -06:00
Dan Moseley f05c4f6393 Add NS1.3 support to Channels (dotnet/corefx#25697)
* Add NS1.3 support to Channels

* Unify configs

* Add more supported fx

* Fix supported fx

* Add uap

* Remove redundant TFM


Commit migrated from https://github.com/dotnet/corefx/commit/cc8b1f50b288d25170d8e8cc65294d0f18591776
2017-12-13 13:29:25 -08:00
Stephen Toub 91c4e41b91 Fill a few System.Threading.Channels test gaps (dotnet/corefx#25141)
Coverage now at 99.8% line and 98.5% branch.

Commit migrated from https://github.com/dotnet/corefx/commit/62125e3c88de231153437be6cfcef4ce29eee922
2017-11-08 23:04:56 -05:00
Stephen Toub 11ec4f96bb Add System.Threading.Channels perf tests
Core perf tests.  More can be added later.


Commit migrated from https://github.com/dotnet/corefx/commit/0582579451b6d6c5701f9fa2a407b060a03e8925
2017-11-02 23:54:17 -04:00
Stephen Toub 566b3dd2e6 Add back ChannelReader.ReadAsync
In the API review, we'd said to remove ReadAsync if we could, as we didn't like that it encouraged exceptions as control flow, due to exceptions getting thrown when attempting to read from a completed channel.

However, removing it is problematic for a few reasons:
- While for most channels its behavior can be achieved external to the channels on top of TryRead and WaitToReadAsync, that's not the case for UnbufferedChannel.  UnbufferedChannel.ReadAsync provides unique functionality that can only be achieved from within the implementation, as reads need to exist concurrently with writes in order for them to pair up.
- Channels in go don't have the notion of completion, which means the ReadAsync equivalent is very common there.  Any code written in that style and trying to port to this will expect a similar function but will instead be forced to emulate it with WaitToReadAsync/TryRead.

As such, I'm putting it back as a base virtual method and an override just on UnbufferedChannel's implementation.


Commit migrated from https://github.com/dotnet/corefx/commit/3c73f4621fe891aa25e97be2bbf772d7a747d263
2017-11-02 23:54:17 -04:00
Stephen Toub 302a648a7d Address System.Threading.Channels PR feedback (dotnet/corefx#24955)
Addressing a few pieces of feedback on the previous PR, plus some auto-cleanup.

Commit migrated from https://github.com/dotnet/corefx/commit/9a90c2e1fcfb3276275a39f6cdc383e8a3012df0
2017-10-30 15:02:02 -04:00
Stephen Toub 51c3bdd745 Disable reflection-based debugger System.Threading.Channels tests on uapaot (dotnet/corefx#24956)
Also remove the duplicated DebuggerAttributes.cs file.

Commit migrated from https://github.com/dotnet/corefx/commit/2544e71349ce03259d0141486dc5e2d52716768b
2017-10-30 12:19:50 -04:00
Stephen Toub 066b7c101b Boost code coverage
And a few minor resulting fixes.


Commit migrated from https://github.com/dotnet/corefx/commit/283af038c1c09b324e76acc8bb2c8a447b6664e6
2017-10-25 19:45:04 -04:00
Stephen Toub a8d1d8eba7 Consistently check for cancellation before operations
Commit migrated from https://github.com/dotnet/corefx/commit/0558ff46df30b93b22d7567d2f58f9b1755df7cd
2017-10-25 19:45:03 -04:00
Stephen Toub e424fbb097 Add System.Threading.Channels to corefx
Bring the source over from corefxlab, add a package, get everything building, etc.


Commit migrated from https://github.com/dotnet/corefx/commit/c8ec3a850bd05aa8d8a6067071b723366b5648a3
2017-10-25 19:45:02 -04:00