本文整理汇总了C#中Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle类的典型用法代码示例。如果您正苦于以下问题:C# UvStreamHandle类的具体用法?C# UvStreamHandle怎么用?C# UvStreamHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UvStreamHandle类属于Microsoft.AspNet.Server.Kestrel.Networking命名空间,在下文中一共展示了UvStreamHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Shutdown
public void Shutdown(UvStreamHandle handle, Action<UvShutdownReq, int, object> callback, object state)
{
_callback = callback;
_state = state;
_pin = GCHandle.Alloc(this, GCHandleType.Normal);
_uv.shutdown(this, handle, _uv_shutdown_cb);
}
开发者ID:njmube,项目名称:KestrelHttpServer,代码行数:7,代码来源:UvShutdownReq.cs
示例2: Shutdown
public void Shutdown(UvStreamHandle handle, Action<UvShutdownReq, int, object> callback, object state)
{
_callback = callback;
_state = state;
Pin();
_uv.shutdown(this, handle, _uv_shutdown_cb);
}
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:7,代码来源:UvShutdownReq.cs
示例3: SocketOutput
public SocketOutput(KestrelThread thread, UvStreamHandle socket, long connectionId, IKestrelTrace log)
{
_thread = thread;
_socket = socket;
_connectionId = connectionId;
_log = log;
_callbacksPending = new Queue<CallbackContext>();
}
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:8,代码来源:SocketOutput.cs
示例4: Write
public unsafe void Write(
UvStreamHandle handle,
MemoryPoolIterator2 start,
MemoryPoolIterator2 end,
int nBuffers,
Action<UvWriteReq, int, Exception, object> callback,
object state)
{
try
{
// add GCHandle to keeps this SafeHandle alive while request processing
_pins.Add(GCHandle.Alloc(this, GCHandleType.Normal));
var pBuffers = (Libuv.uv_buf_t*)_bufs;
if (nBuffers > BUFFER_COUNT)
{
// create and pin buffer array when it's larger than the pre-allocated one
var bufArray = new Libuv.uv_buf_t[nBuffers];
var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
_pins.Add(gcHandle);
pBuffers = (Libuv.uv_buf_t*)gcHandle.AddrOfPinnedObject();
}
var block = start.Block;
for (var index = 0; index < nBuffers; index++)
{
var blockStart = block == start.Block ? start.Index : block.Data.Offset;
var blockEnd = block == end.Block ? end.Index : block.Data.Offset + block.Data.Count;
// create and pin each segment being written
pBuffers[index] = Libuv.buf_init(
block.Pin() + blockStart,
blockEnd - blockStart);
block = block.Next;
}
_callback = callback;
_state = state;
_uv.write(this, handle, pBuffers, nBuffers, _uv_write_cb);
}
catch
{
_callback = null;
_state = null;
Unpin(this);
var block = start.Block;
for (var index = 0; index < nBuffers; index++)
{
block.Unpin();
block = block.Next;
}
throw;
}
}
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:57,代码来源:UvWriteReq.cs
示例5: Connection
public Connection(ListenerContext context, UvStreamHandle socket) : base(context)
{
_socket = socket;
ConnectionControl = this;
_connectionId = Interlocked.Increment(ref _lastConnectionId);
_rawSocketInput = new SocketInput(Memory2, ThreadPool);
_rawSocketOutput = new SocketOutput(Thread, _socket, Memory2, this, _connectionId, Log, ThreadPool, WriteReqPool);
}
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:10,代码来源:Connection.cs
示例6: Connection
public Connection(ListenerContext context, UvStreamHandle socket)
: base(context)
{
_socket = socket;
ConnectionControl = this;
_connectionId = Interlocked.Increment(ref _lastConnectionId);
SocketInput = new SocketInput(Memory2);
SocketOutput = new SocketOutput(Thread, _socket, _connectionId, Log);
_frame = new Frame(this);
}
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:12,代码来源:Connection.cs
示例7: ConnectionCallback
protected static void ConnectionCallback(UvStreamHandle stream, int status, Exception error, object state)
{
var listener = (Listener) state;
if (error != null)
{
listener.Log.LogError("Listener.ConnectionCallback ", error);
}
else
{
listener.OnConnection(stream, status);
}
}
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:12,代码来源:Listener.cs
示例8: Write
public unsafe void Write(
UvStreamHandle handle,
ArraySegment<ArraySegment<byte>> bufs,
Action<UvWriteReq, int, Exception, object> callback,
object state)
{
try
{
// add GCHandle to keeps this SafeHandle alive while request processing
_pins.Add(GCHandle.Alloc(this, GCHandleType.Normal));
var pBuffers = (Libuv.uv_buf_t*)_bufs;
var nBuffers = bufs.Count;
if (nBuffers > BUFFER_COUNT)
{
// create and pin buffer array when it's larger than the pre-allocated one
var bufArray = new Libuv.uv_buf_t[nBuffers];
var gcHandle = GCHandle.Alloc(bufArray, GCHandleType.Pinned);
_pins.Add(gcHandle);
pBuffers = (Libuv.uv_buf_t*)gcHandle.AddrOfPinnedObject();
}
for (var index = 0; index != nBuffers; ++index)
{
// create and pin each segment being written
var buf = bufs.Array[bufs.Offset + index];
var gcHandle = GCHandle.Alloc(buf.Array, GCHandleType.Pinned);
_pins.Add(gcHandle);
pBuffers[index] = Libuv.buf_init(
gcHandle.AddrOfPinnedObject() + buf.Offset,
buf.Count);
}
_callback = callback;
_state = state;
_uv.write(this, handle, pBuffers, nBuffers, _uv_write_cb);
}
catch
{
_callback = null;
_state = null;
Unpin(this);
throw;
}
}
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:46,代码来源:UvWriteReq.cs
示例9: OnConnection
/// <summary>
/// Handles an incoming connection
/// </summary>
/// <param name="listenSocket">Socket being used to listen on</param>
/// <param name="status">Connection status</param>
protected override void OnConnection(UvStreamHandle listenSocket, int status)
{
var acceptSocket = new UvTcpHandle(Log);
acceptSocket.Init(Thread.Loop, Thread.QueueCloseHandle);
try
{
listenSocket.Accept(acceptSocket);
}
catch (UvException ex)
{
Log.LogError("TcpListenerPrimary.OnConnection", ex);
return;
}
DispatchConnection(acceptSocket);
}
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:22,代码来源:TcpListenerPrimary.cs
示例10: OnConnection
/// <summary>
/// Handles an incoming connection
/// </summary>
/// <param name="listenSocket">Socket being used to listen on</param>
/// <param name="status">Connection status</param>
protected override void OnConnection(UvStreamHandle listenSocket, int status)
{
var acceptSocket = new UvPipeHandle(Log);
acceptSocket.Init(Thread.Loop, false);
try
{
listenSocket.Accept(acceptSocket);
}
catch (UvException ex)
{
Log.LogError("PipeListener.OnConnection", ex);
return;
}
DispatchConnection(acceptSocket);
}
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:22,代码来源:PipeListener.cs
示例11: OnListenPipe
private void OnListenPipe(UvStreamHandle pipe, int status, Exception error, object state)
{
if (status < 0)
{
return;
}
var dispatchPipe = new UvPipeHandle();
dispatchPipe.Init(Thread.Loop, true);
try
{
pipe.Accept(dispatchPipe);
}
catch (Exception)
{
dispatchPipe.Dispose();
return;
}
_dispatchPipes.Add(dispatchPipe);
}
开发者ID:justkao,项目名称:KestrelHttpServer,代码行数:20,代码来源:ListenerPrimary.cs
示例12: OnListenPipe
private void OnListenPipe(UvStreamHandle pipe, int status, Exception error)
{
if (status < 0)
{
return;
}
var dispatchPipe = new UvPipeHandle(Log);
dispatchPipe.Init(Thread.Loop, true);
try
{
pipe.Accept(dispatchPipe);
}
catch (UvException ex)
{
dispatchPipe.Dispose();
Log.LogError("ListenerPrimary.OnListenPipe", ex);
return;
}
_dispatchPipes.Add(dispatchPipe);
}
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:23,代码来源:ListenerPrimary.cs
示例13: DispatchConnection
protected override void DispatchConnection(UvStreamHandle socket)
{
var index = _dispatchIndex++ % (_dispatchPipes.Count + 1);
if (index == _dispatchPipes.Count)
{
base.DispatchConnection(socket);
}
else
{
var dispatchPipe = _dispatchPipes[index];
var write = new UvWriteReq(Log);
write.Init(Thread.Loop);
write.Write2(
dispatchPipe,
_dummyMessage,
socket,
(write2, status, error, state) =>
{
write2.Dispose();
((UvStreamHandle)state).Dispose();
},
socket);
}
}
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:24,代码来源:ListenerPrimary.cs
示例14: SocketOutput
public SocketOutput(
KestrelThread thread,
UvStreamHandle socket,
MemoryPool2 memory,
Connection connection,
long connectionId,
IKestrelTrace log,
IThreadPool threadPool,
Queue<UvWriteReq> writeReqPool)
{
_thread = thread;
_socket = socket;
_connection = connection;
_connectionId = connectionId;
_log = log;
_threadPool = threadPool;
_tasksPending = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
_tasksCompleted = new Queue<TaskCompletionSource<object>>(_initialTaskQueues);
_writeContextPool = new Queue<WriteContext>(_maxPooledWriteContexts);
_writeReqPool = writeReqPool;
_head = memory.Lease();
_tail = _head;
}
开发者ID:leloulight,项目名称:KestrelHttpServer,代码行数:24,代码来源:SocketOutput.cs
示例15: Contextualize
internal void Contextualize(
SocketOutput socketOutput,
UvStreamHandle socket,
ArraySegment<byte> buffer,
Action<Exception, object> callback,
object state)
{
_self = socketOutput;
_socket = socket;
_buffer = buffer;
_callback = callback;
_state = state;
}
开发者ID:fakedob,项目名称:KestrelHttpServer,代码行数:13,代码来源:SocketOutput.cs
示例16: uv_write2
unsafe public static extern int uv_write2(UvRequest req, UvStreamHandle handle, uv_buf_t* bufs, int nbufs, UvStreamHandle sendHandle, uv_write_cb cb);
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:1,代码来源:Libuv.cs
示例17: SocketOutput
public SocketOutput(KestrelThread thread, UvStreamHandle socket)
{
_thread = thread;
_socket = socket;
}
开发者ID:fakedob,项目名称:KestrelHttpServer,代码行数:5,代码来源:SocketOutput.cs
示例18: uv_shutdown
public static extern int uv_shutdown(UvShutdownReq req, UvStreamHandle handle, uv_shutdown_cb cb);
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:1,代码来源:Libuv.cs
示例19: UvWrite
unsafe private int UvWrite(UvRequest req, UvStreamHandle handle, uv_buf_t* bufs, int nbufs, uv_write_cb cb)
{
return _onWrite(handle, new ArraySegment<ArraySegment<byte>>(), status => cb(req.InternalGetHandle(), status));
}
开发者ID:Starcounter,项目名称:KestrelHttpServer,代码行数:4,代码来源:MockLibuv.cs
示例20: Accept
public void Accept(UvStreamHandle handle)
{
_uv.accept(this, handle);
}
开发者ID:rogeralsing,项目名称:KestrelHttpServer,代码行数:4,代码来源:UvStreamHandle.cs
注:本文中的Microsoft.AspNet.Server.Kestrel.Networking.UvStreamHandle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论