Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OverlappedData.cs
Go to the documentation of this file.
2
3namespace System.Threading;
4
5internal sealed class OverlappedData
6{
8
9 internal object _callback;
10
11 internal readonly Overlapped _overlapped;
12
13 private object _userObject;
14
15 private unsafe readonly NativeOverlapped* _pNativeOverlapped;
16
18
19 private int _offsetLow;
20
21 private int _offsetHigh;
22
23 internal unsafe ref int OffsetLow
24 {
25 get
26 {
27 if (_pNativeOverlapped == null)
28 {
29 return ref _offsetLow;
30 }
31 return ref _pNativeOverlapped->OffsetLow;
32 }
33 }
34
35 internal unsafe ref int OffsetHigh
36 {
37 get
38 {
39 if (_pNativeOverlapped == null)
40 {
41 return ref _offsetHigh;
42 }
44 }
45 }
46
47 internal unsafe ref IntPtr EventHandle
48 {
49 get
50 {
51 if (_pNativeOverlapped == null)
52 {
53 return ref _eventHandle;
54 }
56 }
57 }
58
59 internal OverlappedData(Overlapped overlapped)
60 {
61 _overlapped = overlapped;
62 }
63
64 internal unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, object userData)
65 {
66 if (_pNativeOverlapped != null)
67 {
69 }
70 if (iocb != null)
71 {
72 ExecutionContext executionContext = ExecutionContext.Capture();
73 _callback = ((executionContext != null && !executionContext.IsDefault) ? ((object)new _IOCompletionCallback(iocb, executionContext)) : ((object)iocb));
74 }
75 else
76 {
77 _callback = null;
78 }
79 _userObject = userData;
81 }
82
83 internal unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb, object userData)
84 {
85 if (_pNativeOverlapped != null)
86 {
88 }
89 _userObject = userData;
90 _callback = iocb;
92 }
93
94 internal bool IsUserObject(byte[] buffer)
95 {
96 return _userObject == buffer;
97 }
98
99 [MethodImpl(MethodImplOptions.InternalCall)]
101
102 [MethodImpl(MethodImplOptions.InternalCall)]
103 internal unsafe static extern void FreeNativeOverlapped(NativeOverlapped* nativeOverlappedPtr);
104
105 [MethodImpl(MethodImplOptions.InternalCall)]
106 internal unsafe static extern OverlappedData GetOverlappedFromNative(NativeOverlapped* nativeOverlappedPtr);
107
108 [MethodImpl(MethodImplOptions.InternalCall)]
109 internal unsafe static extern void CheckVMForIOPacket(out NativeOverlapped* pNativeOverlapped, out uint errorCode, out uint numBytes);
110}
static string InvalidOperation_Overlapped_Pack
Definition SR.cs:1500
Definition SR.cs:7
static ? ExecutionContext Capture()
unsafe NativeOverlapped * AllocateNativeOverlapped()
unsafe NativeOverlapped * Pack(IOCompletionCallback iocb, object userData)
bool IsUserObject(byte[] buffer)
static unsafe void FreeNativeOverlapped(NativeOverlapped *nativeOverlappedPtr)
unsafe readonly NativeOverlapped * _pNativeOverlapped
static unsafe OverlappedData GetOverlappedFromNative(NativeOverlapped *nativeOverlappedPtr)
OverlappedData(Overlapped overlapped)
static unsafe void CheckVMForIOPacket(out NativeOverlapped *pNativeOverlapped, out uint errorCode, out uint numBytes)
readonly Overlapped _overlapped
unsafe NativeOverlapped * UnsafePack(IOCompletionCallback iocb, object userData)
unsafe delegate void IOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped *pOVERLAP)