Skip to content

Commit

Permalink
yak
Browse files Browse the repository at this point in the history
  • Loading branch information
mgravell committed Aug 1, 2018
1 parent 83498ce commit 7691c24
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Shared.ruleset
Expand Up @@ -11,6 +11,6 @@
<Rule Id="RCS1141" Action="None" />
<Rule Id="RCS1146" Action="None" />
<Rule Id="RCS1154" Action="None" />
<Rule Id="RCS1191" Action="None" />
<Rule Id="RCS1191" Action="None" />
</Rules>
</RuleSet>
59 changes: 57 additions & 2 deletions src/Pipelines.Sockets.Unofficial/SocketConnection.cs
Expand Up @@ -5,34 +5,84 @@
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;

namespace Pipelines.Sockets.Unofficial
{
/// <summary>
/// When possible, determines how the pipe first reached a close state
/// </summary>
public enum PipeShutdownKind
{
// 0**: things to do with the pipe
/// <summary>
/// The pipe is still open
/// </summary>
None = 0, // important this stays zero for default value, etc
/// <summary>
/// The pipe itself was disposed
/// </summary>
PipeDisposed = 1,

// 1**: things to do with the read loop
/// <summary>
/// The socket-reader reached a natural EOF from the socket
/// </summary>
ReadEndOfStream = 100,
/// <summary>
/// The socket-reader encountered a dispose failure
/// </summary>
ReadDisposed = 101,
/// <summary>
/// The socket-reader encountered an IO failure
/// </summary>
ReadIOException = 102,
/// <summary>
/// The socket-reader encountered a general failure
/// </summary>
ReadException = 103,
/// <summary>
/// The socket-reader encountered a socket failure - the SocketError may be populated
/// </summary>
ReadSocketError = 104,

// 2**: things to do with the write loop
/// <summary>
/// The socket-writerreached a natural EOF from the pipe
/// </summary>
WriteEndOfStream = 200,
/// <summary>
/// The socket-writer encountered a dispose failure
/// </summary>
WriteDisposed = 201,
/// <summary>
/// The socket-writer encountered an IO failure
/// </summary>
WriteIOException = 203,
/// <summary>
/// The socket-writer encountered a general failure
/// </summary>
WriteException = 204,
/// <summary>
/// The socket-writer encountered a socket failure - the SocketError may be populated
/// </summary>
WriteSocketError = 205,

// 2**: things to do with the reader/writer themselves
/// <summary>
/// The input's reader was completed
/// </summary>
InputReaderCompleted = 300,
/// <summary>
/// The input's writer was completed
/// </summary>
InputWriterCompleted = 301,
/// <summary>
/// The output's reader was completed
/// </summary>
OutputReaderCompleted = 302,
/// <summary>
/// The input's writer was completed
/// </summary>
OutputWriterCompleted = 303,
}

Expand All @@ -46,7 +96,13 @@ public sealed partial class SocketConnection : IDuplexPipe, IDisposable
#endif

private int _socketShutdownKind;
/// <summary>
/// When possible, determines how the pipe first reached a close state
/// </summary>
public PipeShutdownKind ShutdownKind => (PipeShutdownKind)Thread.VolatileRead(ref _socketShutdownKind);
/// <summary>
/// When the ShutdownKind relates to a socket error, may contain the socket error code
/// </summary>
public SocketError SocketError {get; private set;}

private bool TrySetShutdown(PipeShutdownKind kind) => kind != PipeShutdownKind.None
Expand Down Expand Up @@ -129,7 +185,6 @@ public void Dispose()
/// The underlying socket for this connection
/// </summary>
public Socket Socket { get; }
public static List<ArraySegment<byte>> SpareBuffer { get => _spareBuffer; set => _spareBuffer = value; }

private readonly Pipe _sendToSocket, _receiveFromSocket;
// TODO: flagify
Expand Down
2 changes: 1 addition & 1 deletion src/Pipelines.Sockets.Unofficial/StreamConnection.cs
Expand Up @@ -47,7 +47,7 @@ public static AsyncPipeStream GetDuplex(IDuplexPipe pipe, string name = null)
/// <summary>
/// Create a write-only stream that feeds the provided PipeReader
/// </summary>
/// <param name="reader">The reader to wrap</param>
/// <param name="writer">The writer to wrap</param>
/// <param name="name">The logical name of the reader</param>
public static Stream GetWriter(PipeWriter writer, string name = null)
=> new AsyncPipeStream(null, writer, name);
Expand Down
2 changes: 1 addition & 1 deletion version.json
@@ -1,6 +1,6 @@
{
"version": "0.2.1-alpha.{height}",
"assemblyVersion": "0.2.0.0",
"assemblyVersion": "0.2",
"publicReleaseRefSpec": [
"^refs/heads/master$",
"^refs/tags/v\\d+\\.\\d+"
Expand Down

0 comments on commit 7691c24

Please sign in to comment.