rename some ill-named enums and move them to the right files

pull/6640/head
Jan Tattermusch 9 years ago
parent a7db28fe4d
commit e0af286620
  1. 2
      src/csharp/Grpc.Core.Tests/Internal/CompletionQueueSafeHandleTest.cs
  2. 2
      src/csharp/Grpc.Core.Tests/Internal/TimespecTest.cs
  3. 3
      src/csharp/Grpc.Core/Grpc.Core.csproj
  4. 39
      src/csharp/Grpc.Core/Internal/CallError.cs
  5. 53
      src/csharp/Grpc.Core/Internal/ClockType.cs
  6. 17
      src/csharp/Grpc.Core/Internal/CompletionQueueEvent.cs
  7. 4
      src/csharp/Grpc.Core/Internal/GrpcThreadPool.cs
  8. 80
      src/csharp/Grpc.Core/Internal/NativeMethods.cs
  9. 2
      src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
  10. 22
      src/csharp/Grpc.Core/Internal/Timespec.cs

@ -60,7 +60,7 @@ namespace Grpc.Core.Internal.Tests
var ev = cq.Next(); var ev = cq.Next();
cq.Dispose(); cq.Dispose();
GrpcEnvironment.Release(); GrpcEnvironment.Release();
Assert.AreEqual(GRPCCompletionType.Shutdown, ev.type); Assert.AreEqual(CompletionQueueEvent.CompletionType.Shutdown, ev.type);
Assert.AreNotEqual(IntPtr.Zero, ev.success); Assert.AreNotEqual(IntPtr.Zero, ev.success);
Assert.AreEqual(IntPtr.Zero, ev.tag); Assert.AreEqual(IntPtr.Zero, ev.tag);
} }

@ -108,7 +108,7 @@ namespace Grpc.Core.Internal.Tests
Assert.Throws(typeof(InvalidOperationException), Assert.Throws(typeof(InvalidOperationException),
() => new Timespec(0, 1000 * 1000 * 1000).ToDateTime()); () => new Timespec(0, 1000 * 1000 * 1000).ToDateTime());
Assert.Throws(typeof(InvalidOperationException), Assert.Throws(typeof(InvalidOperationException),
() => new Timespec(0, 0, GPRClockType.Monotonic).ToDateTime()); () => new Timespec(0, 0, ClockType.Monotonic).ToDateTime());
} }
[Test] [Test]

@ -74,7 +74,6 @@
<Compile Include="Internal\CallSafeHandle.cs" /> <Compile Include="Internal\CallSafeHandle.cs" />
<Compile Include="Internal\ChannelSafeHandle.cs" /> <Compile Include="Internal\ChannelSafeHandle.cs" />
<Compile Include="Internal\CompletionQueueSafeHandle.cs" /> <Compile Include="Internal\CompletionQueueSafeHandle.cs" />
<Compile Include="Internal\Enums.cs" />
<Compile Include="Internal\SafeHandleZeroIsInvalid.cs" /> <Compile Include="Internal\SafeHandleZeroIsInvalid.cs" />
<Compile Include="Internal\Timespec.cs" /> <Compile Include="Internal\Timespec.cs" />
<Compile Include="Internal\GrpcThreadPool.cs" /> <Compile Include="Internal\GrpcThreadPool.cs" />
@ -136,6 +135,8 @@
<Compile Include="Internal\InterceptingCallInvoker.cs" /> <Compile Include="Internal\InterceptingCallInvoker.cs" />
<Compile Include="Internal\ServerRpcNew.cs" /> <Compile Include="Internal\ServerRpcNew.cs" />
<Compile Include="Internal\ClientSideStatus.cs" /> <Compile Include="Internal\ClientSideStatus.cs" />
<Compile Include="Internal\ClockType.cs" />
<Compile Include="Internal\CallError.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="Grpc.Core.nuspec" /> <None Include="Grpc.Core.nuspec" />

@ -40,7 +40,7 @@ namespace Grpc.Core.Internal
/// <summary> /// <summary>
/// grpc_call_error from grpc/grpc.h /// grpc_call_error from grpc/grpc.h
/// </summary> /// </summary>
internal enum GRPCCallError internal enum CallError
{ {
/* everything went ok */ /* everything went ok */
OK = 0, OK = 0,
@ -70,42 +70,9 @@ namespace Grpc.Core.Internal
/// <summary> /// <summary>
/// Checks the call API invocation's result is OK. /// Checks the call API invocation's result is OK.
/// </summary> /// </summary>
public static void CheckOk(this GRPCCallError callError) public static void CheckOk(this CallError callError)
{ {
GrpcPreconditions.CheckState(callError == GRPCCallError.OK, "Call error: " + callError); GrpcPreconditions.CheckState(callError == CallError.OK, "Call error: " + callError);
} }
} }
/// <summary>
/// grpc_completion_type from grpc/grpc.h
/// </summary>
internal enum GRPCCompletionType
{
/* Shutting down */
Shutdown,
/* No event before timeout */
Timeout,
/* operation completion */
OpComplete
}
/// <summary>
/// gpr_clock_type from grpc/support/time.h
/// </summary>
internal enum GPRClockType
{
/* Monotonic clock */
Monotonic,
/* Realtime clock */
Realtime,
/* Precise clock good for performance profiling. */
Precise,
/* Timespan - the distance between two time points */
Timespan
}
} }

@ -0,0 +1,53 @@
#region Copyright notice and license
// Copyright 2015, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endregion
namespace Grpc.Core.Internal
{
/// <summary>
/// gpr_clock_type from grpc/support/time.h
/// </summary>
internal enum ClockType
{
/* Monotonic clock */
Monotonic,
/* Realtime clock */
Realtime,
/* Precise clock good for performance profiling. */
Precise,
/* Timespan - the distance between two time points */
Timespan
}
}

@ -44,7 +44,7 @@ namespace Grpc.Core.Internal
{ {
static readonly NativeMethods Native = NativeMethods.Get(); static readonly NativeMethods Native = NativeMethods.Get();
public GRPCCompletionType type; public CompletionType type;
public int success; public int success;
public IntPtr tag; public IntPtr tag;
@ -55,5 +55,20 @@ namespace Grpc.Core.Internal
return Native.grpcsharp_sizeof_grpc_event(); return Native.grpcsharp_sizeof_grpc_event();
} }
} }
/// <summary>
/// grpc_completion_type from grpc/grpc.h
/// </summary>
internal enum CompletionType
{
/* Shutting down */
Shutdown,
/* No event before timeout */
Timeout,
/* operation completion */
OpComplete
}
} }
} }

@ -118,7 +118,7 @@ namespace Grpc.Core.Internal
do do
{ {
ev = cq.Next(); ev = cq.Next();
if (ev.type == GRPCCompletionType.OpComplete) if (ev.type == CompletionQueueEvent.CompletionType.OpComplete)
{ {
bool success = (ev.success != 0); bool success = (ev.success != 0);
IntPtr tag = ev.tag; IntPtr tag = ev.tag;
@ -133,7 +133,7 @@ namespace Grpc.Core.Internal
} }
} }
} }
while (ev.type != GRPCCompletionType.Shutdown); while (ev.type != CompletionQueueEvent.CompletionType.Shutdown);
} }
} }
} }

@ -418,33 +418,33 @@ namespace Grpc.Core.Internal
public delegate CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create_delegate(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2); public delegate CallCredentialsSafeHandle grpcsharp_composite_call_credentials_create_delegate(CallCredentialsSafeHandle creds1, CallCredentialsSafeHandle creds2);
public delegate void grpcsharp_call_credentials_release_delegate(IntPtr credentials); public delegate void grpcsharp_call_credentials_release_delegate(IntPtr credentials);
public delegate GRPCCallError grpcsharp_call_cancel_delegate(CallSafeHandle call); public delegate CallError grpcsharp_call_cancel_delegate(CallSafeHandle call);
public delegate GRPCCallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description); public delegate CallError grpcsharp_call_cancel_with_status_delegate(CallSafeHandle call, StatusCode status, string description);
public delegate GRPCCallError grpcsharp_call_start_unary_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_start_unary_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags);
public delegate GRPCCallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_start_client_streaming_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray);
public delegate GRPCCallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_start_server_streaming_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen,
MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); MetadataArraySafeHandle metadataArray, WriteFlags writeFlags);
public delegate GRPCCallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_start_duplex_streaming_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray);
public delegate GRPCCallError grpcsharp_call_send_message_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_send_message_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata); BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata);
public delegate GRPCCallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_send_close_from_client_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
public delegate GRPCCallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_send_status_from_server_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, StatusCode statusCode, string statusMessage, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, BatchContextSafeHandle ctx, StatusCode statusCode, string statusMessage, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata,
byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags);
public delegate GRPCCallError grpcsharp_call_recv_message_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_recv_message_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
public delegate GRPCCallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_recv_initial_metadata_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
public delegate GRPCCallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_start_serverside_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
public delegate GRPCCallError grpcsharp_call_send_initial_metadata_delegate(CallSafeHandle call, public delegate CallError grpcsharp_call_send_initial_metadata_delegate(CallSafeHandle call,
BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray);
public delegate GRPCCallError grpcsharp_call_set_credentials_delegate(CallSafeHandle call, CallCredentialsSafeHandle credentials); public delegate CallError grpcsharp_call_set_credentials_delegate(CallSafeHandle call, CallCredentialsSafeHandle credentials);
public delegate CStringSafeHandle grpcsharp_call_get_peer_delegate(CallSafeHandle call); public delegate CStringSafeHandle grpcsharp_call_get_peer_delegate(CallSafeHandle call);
public delegate void grpcsharp_call_destroy_delegate(IntPtr call); public delegate void grpcsharp_call_destroy_delegate(IntPtr call);
@ -497,19 +497,19 @@ namespace Grpc.Core.Internal
public delegate int grpcsharp_server_add_insecure_http2_port_delegate(ServerSafeHandle server, string addr); public delegate int grpcsharp_server_add_insecure_http2_port_delegate(ServerSafeHandle server, string addr);
public delegate int grpcsharp_server_add_secure_http2_port_delegate(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds); public delegate int grpcsharp_server_add_secure_http2_port_delegate(ServerSafeHandle server, string addr, ServerCredentialsSafeHandle creds);
public delegate void grpcsharp_server_start_delegate(ServerSafeHandle server); public delegate void grpcsharp_server_start_delegate(ServerSafeHandle server);
public delegate GRPCCallError grpcsharp_server_request_call_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); public delegate CallError grpcsharp_server_request_call_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx);
public delegate void grpcsharp_server_cancel_all_calls_delegate(ServerSafeHandle server); public delegate void grpcsharp_server_cancel_all_calls_delegate(ServerSafeHandle server);
public delegate void grpcsharp_server_shutdown_and_notify_callback_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); public delegate void grpcsharp_server_shutdown_and_notify_callback_delegate(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx);
public delegate void grpcsharp_server_destroy_delegate(IntPtr server); public delegate void grpcsharp_server_destroy_delegate(IntPtr server);
public delegate Timespec gprsharp_now_delegate(GPRClockType clockType); public delegate Timespec gprsharp_now_delegate(ClockType clockType);
public delegate Timespec gprsharp_inf_future_delegate(GPRClockType clockType); public delegate Timespec gprsharp_inf_future_delegate(ClockType clockType);
public delegate Timespec gprsharp_inf_past_delegate(GPRClockType clockType); public delegate Timespec gprsharp_inf_past_delegate(ClockType clockType);
public delegate Timespec gprsharp_convert_clock_type_delegate(Timespec t, GPRClockType targetClock); public delegate Timespec gprsharp_convert_clock_type_delegate(Timespec t, ClockType targetClock);
public delegate int gprsharp_sizeof_timespec_delegate(); public delegate int gprsharp_sizeof_timespec_delegate();
public delegate GRPCCallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback); public delegate CallError grpcsharp_test_callback_delegate([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback);
public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr); public delegate IntPtr grpcsharp_test_nop_delegate(IntPtr ptr);
} }
@ -587,59 +587,59 @@ namespace Grpc.Core.Internal
// CallSafeHandle // CallSafeHandle
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_cancel(CallSafeHandle call); public static extern CallError grpcsharp_call_cancel(CallSafeHandle call);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description); public static extern CallError grpcsharp_call_cancel_with_status(CallSafeHandle call, StatusCode status, string description);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_start_unary(CallSafeHandle call, public static extern CallError grpcsharp_call_start_unary(CallSafeHandle call,
BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, MetadataArraySafeHandle metadataArray, WriteFlags writeFlags);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_start_client_streaming(CallSafeHandle call, public static extern CallError grpcsharp_call_start_client_streaming(CallSafeHandle call,
BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_start_server_streaming(CallSafeHandle call, public static extern CallError grpcsharp_call_start_server_streaming(CallSafeHandle call,
BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen,
MetadataArraySafeHandle metadataArray, WriteFlags writeFlags); MetadataArraySafeHandle metadataArray, WriteFlags writeFlags);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call, public static extern CallError grpcsharp_call_start_duplex_streaming(CallSafeHandle call,
BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_send_message(CallSafeHandle call, public static extern CallError grpcsharp_call_send_message(CallSafeHandle call,
BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata); BatchContextSafeHandle ctx, byte[] sendBuffer, UIntPtr sendBufferLen, WriteFlags writeFlags, bool sendEmptyInitialMetadata);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_send_close_from_client(CallSafeHandle call, public static extern CallError grpcsharp_call_send_close_from_client(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_send_status_from_server(CallSafeHandle call, public static extern CallError grpcsharp_call_send_status_from_server(CallSafeHandle call,
BatchContextSafeHandle ctx, StatusCode statusCode, string statusMessage, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata, BatchContextSafeHandle ctx, StatusCode statusCode, string statusMessage, MetadataArraySafeHandle metadataArray, bool sendEmptyInitialMetadata,
byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags); byte[] optionalSendBuffer, UIntPtr optionalSendBufferLen, WriteFlags writeFlags);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_recv_message(CallSafeHandle call, public static extern CallError grpcsharp_call_recv_message(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call, public static extern CallError grpcsharp_call_recv_initial_metadata(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_start_serverside(CallSafeHandle call, public static extern CallError grpcsharp_call_start_serverside(CallSafeHandle call,
BatchContextSafeHandle ctx); BatchContextSafeHandle ctx);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_send_initial_metadata(CallSafeHandle call, public static extern CallError grpcsharp_call_send_initial_metadata(CallSafeHandle call,
BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray); BatchContextSafeHandle ctx, MetadataArraySafeHandle metadataArray);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_call_set_credentials(CallSafeHandle call, CallCredentialsSafeHandle credentials); public static extern CallError grpcsharp_call_set_credentials(CallSafeHandle call, CallCredentialsSafeHandle credentials);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern CStringSafeHandle grpcsharp_call_get_peer(CallSafeHandle call); public static extern CStringSafeHandle grpcsharp_call_get_peer(CallSafeHandle call);
@ -785,7 +785,7 @@ namespace Grpc.Core.Internal
public static extern void grpcsharp_server_start(ServerSafeHandle server); public static extern void grpcsharp_server_start(ServerSafeHandle server);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_server_request_call(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx); public static extern CallError grpcsharp_server_request_call(ServerSafeHandle server, CompletionQueueSafeHandle cq, BatchContextSafeHandle ctx);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern void grpcsharp_server_cancel_all_calls(ServerSafeHandle server); public static extern void grpcsharp_server_cancel_all_calls(ServerSafeHandle server);
@ -799,16 +799,16 @@ namespace Grpc.Core.Internal
// Timespec // Timespec
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern Timespec gprsharp_now(GPRClockType clockType); public static extern Timespec gprsharp_now(ClockType clockType);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern Timespec gprsharp_inf_future(GPRClockType clockType); public static extern Timespec gprsharp_inf_future(ClockType clockType);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern Timespec gprsharp_inf_past(GPRClockType clockType); public static extern Timespec gprsharp_inf_past(ClockType clockType);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern Timespec gprsharp_convert_clock_type(Timespec t, GPRClockType targetClock); public static extern Timespec gprsharp_convert_clock_type(Timespec t, ClockType targetClock);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern int gprsharp_sizeof_timespec(); public static extern int gprsharp_sizeof_timespec();
@ -816,7 +816,7 @@ namespace Grpc.Core.Internal
// Testing // Testing
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern GRPCCallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback); public static extern CallError grpcsharp_test_callback([MarshalAs(UnmanagedType.FunctionPtr)] OpCompletionDelegate callback);
[DllImport("grpc_csharp_ext.dll")] [DllImport("grpc_csharp_ext.dll")]
public static extern IntPtr grpcsharp_test_nop(IntPtr ptr); public static extern IntPtr grpcsharp_test_nop(IntPtr ptr);

@ -317,7 +317,7 @@ namespace Grpc.Core.Internal
where TRequest : class where TRequest : class
where TResponse : class where TResponse : class
{ {
DateTime realtimeDeadline = newRpc.Deadline.ToClockType(GPRClockType.Realtime).ToDateTime(); DateTime realtimeDeadline = newRpc.Deadline.ToClockType(ClockType.Realtime).ToDateTime();
return new ServerCallContext(newRpc.Call, newRpc.Method, newRpc.Host, peer, realtimeDeadline, return new ServerCallContext(newRpc.Call, newRpc.Method, newRpc.Host, peer, realtimeDeadline,
newRpc.RequestMetadata, cancellationToken, serverResponseStream.WriteResponseHeadersAsync, serverResponseStream); newRpc.RequestMetadata, cancellationToken, serverResponseStream.WriteResponseHeadersAsync, serverResponseStream);

@ -49,11 +49,11 @@ namespace Grpc.Core.Internal
static readonly NativeMethods Native = NativeMethods.Get(); static readonly NativeMethods Native = NativeMethods.Get();
static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
public Timespec(long tv_sec, int tv_nsec) : this(tv_sec, tv_nsec, GPRClockType.Realtime) public Timespec(long tv_sec, int tv_nsec) : this(tv_sec, tv_nsec, ClockType.Realtime)
{ {
} }
public Timespec(long tv_sec, int tv_nsec, GPRClockType clock_type) public Timespec(long tv_sec, int tv_nsec, ClockType clock_type)
{ {
this.tv_sec = tv_sec; this.tv_sec = tv_sec;
this.tv_nsec = tv_nsec; this.tv_nsec = tv_nsec;
@ -62,7 +62,7 @@ namespace Grpc.Core.Internal
private long tv_sec; private long tv_sec;
private int tv_nsec; private int tv_nsec;
private GPRClockType clock_type; private ClockType clock_type;
/// <summary> /// <summary>
/// Timespec a long time in the future. /// Timespec a long time in the future.
@ -71,7 +71,7 @@ namespace Grpc.Core.Internal
{ {
get get
{ {
return new Timespec(long.MaxValue, 0, GPRClockType.Realtime); return new Timespec(long.MaxValue, 0, ClockType.Realtime);
} }
} }
@ -82,7 +82,7 @@ namespace Grpc.Core.Internal
{ {
get get
{ {
return new Timespec(long.MinValue, 0, GPRClockType.Realtime); return new Timespec(long.MinValue, 0, ClockType.Realtime);
} }
} }
@ -93,7 +93,7 @@ namespace Grpc.Core.Internal
{ {
get get
{ {
return Native.gprsharp_now(GPRClockType.Realtime); return Native.gprsharp_now(ClockType.Realtime);
} }
} }
@ -122,7 +122,7 @@ namespace Grpc.Core.Internal
/// <summary> /// <summary>
/// Converts the timespec to desired clock type. /// Converts the timespec to desired clock type.
/// </summary> /// </summary>
public Timespec ToClockType(GPRClockType targetClock) public Timespec ToClockType(ClockType targetClock)
{ {
return Native.gprsharp_convert_clock_type(this, targetClock); return Native.gprsharp_convert_clock_type(this, targetClock);
} }
@ -142,7 +142,7 @@ namespace Grpc.Core.Internal
public DateTime ToDateTime() public DateTime ToDateTime()
{ {
GrpcPreconditions.CheckState(tv_nsec >= 0 && tv_nsec < NanosPerSecond); GrpcPreconditions.CheckState(tv_nsec >= 0 && tv_nsec < NanosPerSecond);
GrpcPreconditions.CheckState(clock_type == GPRClockType.Realtime); GrpcPreconditions.CheckState(clock_type == ClockType.Realtime);
// fast path for InfFuture // fast path for InfFuture
if (this.Equals(InfFuture)) if (this.Equals(InfFuture))
@ -227,7 +227,7 @@ namespace Grpc.Core.Internal
{ {
get get
{ {
return Native.gprsharp_now(GPRClockType.Precise); return Native.gprsharp_now(ClockType.Precise);
} }
} }
@ -245,7 +245,7 @@ namespace Grpc.Core.Internal
{ {
get get
{ {
return Native.gprsharp_inf_future(GPRClockType.Realtime); return Native.gprsharp_inf_future(ClockType.Realtime);
} }
} }
@ -254,7 +254,7 @@ namespace Grpc.Core.Internal
{ {
get get
{ {
return Native.gprsharp_inf_past(GPRClockType.Realtime); return Native.gprsharp_inf_past(ClockType.Realtime);
} }
} }
} }

Loading…
Cancel
Save