mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 23:01:44 +01:00
test & fix
This commit is contained in:
parent
de788bca6b
commit
3c6f5019f2
@ -421,9 +421,12 @@ namespace Capnp.Net.Runtime.Tests.GenImpls
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_tcs?.TrySetResult(0);
|
_tcs?.TrySetResult(0);
|
||||||
|
Assert.IsFalse(IsDisposed);
|
||||||
IsDisposed = true;
|
IsDisposed = true;
|
||||||
|
DisposeCallStack = Environment.StackTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string DisposeCallStack { get; private set; }
|
||||||
public bool IsDisposed { get; private set; }
|
public bool IsDisposed { get; private set; }
|
||||||
|
|
||||||
public virtual Task<string> Foo(uint i, bool j, CancellationToken cancellationToken)
|
public virtual Task<string> Foo(uint i, bool j, CancellationToken cancellationToken)
|
||||||
@ -836,6 +839,7 @@ namespace Capnp.Net.Runtime.Tests.GenImpls
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
ClientToHold?.Dispose();
|
ClientToHold?.Dispose();
|
||||||
|
ClientToHold = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ITestCallOrder> Echo(ITestCallOrder cap, CancellationToken cancellationToken_)
|
public Task<ITestCallOrder> Echo(ITestCallOrder cap, CancellationToken cancellationToken_)
|
||||||
|
@ -311,7 +311,7 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
|
|
||||||
using (var claimer = Skeleton.Claim(cap))
|
using (var claimer = Skeleton.Claim(cap))
|
||||||
{
|
{
|
||||||
var ftask = main.CallFoo(cap, default);
|
var ftask = main.CallFoo(Proxy.Share<ITestInterface>(cap), default);
|
||||||
testbed.MustComplete(ftask);
|
testbed.MustComplete(ftask);
|
||||||
Assert.AreEqual("bar", ftask.Result);
|
Assert.AreEqual("bar", ftask.Result);
|
||||||
|
|
||||||
@ -319,8 +319,8 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
testbed.MustComplete(ctask);
|
testbed.MustComplete(ctask);
|
||||||
Assert.AreEqual(1u, ctask.Result);
|
Assert.AreEqual(1u, ctask.Result);
|
||||||
|
|
||||||
ftask1 = main.CallFoo(cap, default);
|
ftask1 = main.CallFoo(Proxy.Share<ITestInterface>(cap), default);
|
||||||
ftask2 = main.CallFoo(cap, default);
|
ftask2 = main.CallFoo(Proxy.Share<ITestInterface>(cap), default);
|
||||||
}
|
}
|
||||||
|
|
||||||
testbed.MustComplete(ftask1);
|
testbed.MustComplete(ftask1);
|
||||||
@ -804,18 +804,20 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
|
|
||||||
public static void ReexportSenderPromise(ITestbed testbed)
|
public static void ReexportSenderPromise(ITestbed testbed)
|
||||||
{
|
{
|
||||||
var impl = new TestTailCallerImpl(new Counters());
|
var impl = new TestMoreStuffImpl(new Counters());
|
||||||
using (var main = testbed.ConnectMain<ITestTailCaller>(impl))
|
using (var main = testbed.ConnectMain<ITestMoreStuff>(impl))
|
||||||
{
|
{
|
||||||
var tcs = new TaskCompletionSource<ITestTailCallee>();
|
var tcs = new TaskCompletionSource<ITestInterface>();
|
||||||
using (var promise = Proxy.Share(tcs.Task.Eager(true)))
|
var tcsd = new TaskCompletionSource<int>();
|
||||||
|
using (var promise = tcs.Task.Eager(true))
|
||||||
{
|
{
|
||||||
var task1 = main.Foo(1, Proxy.Share(promise));
|
var task1 = main.CallFooWhenResolved(Proxy.Share(promise));
|
||||||
var task2 = main.Foo(2, Proxy.Share(promise));
|
var task2 = main.CallFooWhenResolved(Proxy.Share(promise));
|
||||||
var callee = new TestTailCalleeImpl(new Counters());
|
var callee = new TestInterfaceImpl(new Counters(), tcsd);
|
||||||
tcs.SetResult(callee);
|
tcs.SetResult(callee);
|
||||||
testbed.MustComplete(task1, task2);
|
testbed.MustComplete(task1, task2);
|
||||||
}
|
}
|
||||||
|
testbed.MustComplete(tcsd.Task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ namespace Capnp.Net.Runtime.Tests
|
|||||||
|
|
||||||
T ITestbed.ConnectMain<T>(object main)
|
T ITestbed.ConnectMain<T>(object main)
|
||||||
{
|
{
|
||||||
return (T)main;
|
return Proxy.Share<T>((T)main);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITestbed.FlushCommunication()
|
void ITestbed.FlushCommunication()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -54,7 +55,8 @@ namespace Capnp.Rpc
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void Dispose(bool disposing)
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
foreach (var cap in _ifmap.Values)
|
foreach (var cap in _ifmap.Values.Take(1))
|
||||||
|
// releasing first skeleton is sufficient. Avoid double-Dispose!
|
||||||
{
|
{
|
||||||
cap.Relinquish();
|
cap.Relinquish();
|
||||||
}
|
}
|
||||||
@ -64,7 +66,7 @@ namespace Capnp.Rpc
|
|||||||
|
|
||||||
internal override void Bind(object impl)
|
internal override void Bind(object impl)
|
||||||
{
|
{
|
||||||
foreach (Skeleton skel in _ifmap.Values)
|
foreach (Skeleton skel in _ifmap.Values)
|
||||||
{
|
{
|
||||||
skel.Bind(impl);
|
skel.Bind(impl);
|
||||||
}
|
}
|
||||||
|
@ -154,14 +154,14 @@ namespace Capnp.Rpc
|
|||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
_consumedCap?.Release();
|
_consumedCap.Release();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// When called from the Finalizer, we must not throw.
|
// When called from the Finalizer, we must not throw.
|
||||||
// But when reference counting goes wrong, ConsumedCapability.Release() will throw an InvalidOperationException.
|
// But when reference counting goes wrong, ConsumedCapability.Release() will throw an InvalidOperationException.
|
||||||
// The only option here is to suppress that exception.
|
// The only option here is to suppress that exception.
|
||||||
try { _consumedCap?.Release(); }
|
try { _consumedCap.Release(); }
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user