Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Commit f8a484a

Browse files
Anipikjkotas
authored andcommitted
Moved SafeWaitHandle and cancellationToken to shared (dotnet/coreclr#18662)
* Moving SafeWaitHandle to shared * Moved CancellationToken to shared * _ remove from variable names * Default change to Default(Token) and minor changes * Fixing coreclr unix build * moving semaphoreSlim to shared * splitting safeWaitHandle to .windows and .unix Signed-off-by: dotnet-bot <[email protected]>
1 parent 7b2766c commit f8a484a

File tree

6 files changed

+1323
-2
lines changed

6 files changed

+1323
-2
lines changed

src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.CloseHandle.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ internal partial class Interop
1010
internal partial class Kernel32
1111
{
1212
[DllImport(Libraries.Kernel32, SetLastError = true)]
13-
[return: MarshalAs(UnmanagedType.Bool)]
1413
internal static extern bool CloseHandle(IntPtr handle);
1514
}
1615
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
namespace Microsoft.Win32.SafeHandles
6+
{
7+
public sealed partial class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid
8+
{
9+
protected override bool ReleaseHandle() => Interop.Kernel32.CloseHandle(handle);
10+
}
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Microsoft.Win32.SafeHandles
8+
{
9+
public sealed partial class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid
10+
{
11+
// Called by P/Invoke marshaler
12+
private SafeWaitHandle() : base(true)
13+
{
14+
}
15+
16+
public SafeWaitHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle)
17+
{
18+
SetHandle(existingHandle);
19+
}
20+
}
21+
}

src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\CriticalHandleZeroOrMinusOneIsInvalid.cs" />
2727
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleMinusOneIsInvalid.cs" />
2828
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeHandleZeroOrMinusOneIsInvalid.cs" />
29+
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeWaitHandle.cs" />
2930
<Compile Include="$(MSBuildThisFileDirectory)System\Action.cs" />
3031
<Compile Include="$(MSBuildThisFileDirectory)System\AccessViolationException.cs" />
3132
<Compile Include="$(MSBuildThisFileDirectory)System\ApplicationException.cs" />
@@ -580,6 +581,7 @@
580581
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ApartmentState.cs" />
581582
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\AsyncLocal.cs" />
582583
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\AutoResetEvent.cs" />
584+
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\CancellationToken.cs" />
583585
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\DeferredDisposableLifetime.cs" />
584586
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventResetMode.cs" />
585587
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\EventWaitHandle.cs" />
@@ -594,6 +596,7 @@
594596
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\ReaderWriterLockSlim.cs" />
595597
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Semaphore.cs" />
596598
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SemaphoreFullException.cs" />
599+
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SemaphoreSlim.cs" />
597600
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SendOrPostCallback.cs" />
598601
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SpinWait.cs" />
599602
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\SynchronizationLockException.cs" />
@@ -724,7 +727,6 @@
724727
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Interop.BOOL.cs" />
725728
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Interop.Libraries.cs" />
726729
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CancelIoEx.cs" />
727-
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CloseHandle.cs" />
728730
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FileAttributes.cs" />
729731
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FILE_INFO_BY_HANDLE_CLASS.cs" />
730732
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FileTypes.cs" />
@@ -810,6 +812,8 @@
810812
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CREATEFILE2_EXTENDED_PARAMETERS.cs" />
811813
</ItemGroup>
812814
<ItemGroup Condition="$(TargetsWindows) or '$(FeaturePal)'=='true'">
815+
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeWaitHandle.Windows.cs" />
816+
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.CloseHandle.cs" />
813817
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.Constants.cs" />
814818
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Interop.Errors.cs" />
815819
<Compile Include="$(MSBuildThisFileDirectory)Interop\Windows\Kernel32\Interop.FormatMessage.cs" />

0 commit comments

Comments
 (0)