Skip to content

Eliminate lambdas from Invoke calls #640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ClearScript/V8/SplitProxy/NativeCallbackImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public NativeCallbackImpl(NativeCallback.Handle hCallback)

public void Invoke()
{
V8SplitProxyNative.InvokeNoThrow(instance => instance.NativeCallback_Invoke(Handle));
using (V8SplitProxyNative.InvokeNoThrow(out var instance))
{
instance.NativeCallback_Invoke(Handle);
}
}

#endregion
Expand Down
338 changes: 237 additions & 101 deletions ClearScript/V8/SplitProxy/V8ContextProxyImpl.cs

Large diffs are not rendered by default.

15 changes: 12 additions & 3 deletions ClearScript/V8/SplitProxy/V8DebugListenerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,26 @@ public V8DebugListenerImpl(V8DebugCallback.Handle hCallback)

public void ConnectClient()
{
V8SplitProxyNative.InvokeNoThrow(instance => instance.V8DebugCallback_ConnectClient(Handle));
using (V8SplitProxyNative.InvokeNoThrow(out var instance))
{
instance.V8DebugCallback_ConnectClient(Handle);
}
}

public void SendCommand(string command)
{
V8SplitProxyNative.InvokeNoThrow(instance => instance.V8DebugCallback_SendCommand(Handle, command));
using (V8SplitProxyNative.InvokeNoThrow(out var instance))
{
instance.V8DebugCallback_SendCommand(Handle, command);
}
}

public void DisconnectClient()
{
V8SplitProxyNative.InvokeNoThrow(instance => instance.V8DebugCallback_DisconnectClient(Handle));
using (V8SplitProxyNative.InvokeNoThrow(out var instance))
{
instance.V8DebugCallback_DisconnectClient(Handle);
}
}

#endregion
Expand Down
16 changes: 10 additions & 6 deletions ClearScript/V8/SplitProxy/V8EntityHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,23 @@ private V8EntityHolder(string name)

public void ReleaseEntity()
{
var tempHandle = handle;
if (tempHandle != V8Entity.Handle.Empty)
if (handle != V8Entity.Handle.Empty)
{
V8SplitProxyNative.InvokeNoThrow(instance => instance.V8Entity_Release(tempHandle));
using (V8SplitProxyNative.InvokeNoThrow(out var instance))
{
instance.V8Entity_Release(handle);
}
}
}

public static void Destroy(ref V8EntityHolder holder)
{
var tempHandle = holder.handle;
if (tempHandle != V8Entity.Handle.Empty)
if (holder.handle != V8Entity.Handle.Empty)
{
V8SplitProxyNative.InvokeNoThrow(instance => instance.V8Entity_DestroyHandle(tempHandle));
using (V8SplitProxyNative.InvokeNoThrow(out var instance))
{
instance.V8Entity_DestroyHandle(holder.handle);
}
}

if (holder.registered)
Expand Down
Loading