IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
ThreadAccessor.cs
Go to the documentation of this file.
1using System;
2using System.Threading;
3
5{
6
7#if FIRST_PASS == false && EXPORTER == false && IMPORTER == false
8
12 internal sealed class ThreadAccessor : Accessor<object>
13 {
14
15 Type javaLangThread;
16 Type javaLangThreadGroup;
17
18 FieldAccessor<object> current;
19 FieldAccessor<object, Thread> nativeThread;
20 MethodAccessor<Func<object>> currentThread;
21 MethodAccessor<Func<bool>> interrupted;
22
23 MethodAccessor<Func<object, object>> init;
24 MethodAccessor<Func<object, bool>> isDaemon;
25 MethodAccessor<Func<object, bool>> isInterrupted;
26 MethodAccessor<Action<object>> die;
27 MethodAccessor<Func<object, object>> getThreadGroup;
28
33 public ThreadAccessor(AccessorTypeResolver resolver) :
34 base(resolver, "java.lang.Thread")
35 {
36
37 }
38
39 Type JavaLangThread => Resolve(ref javaLangThread, "java.lang.Thread");
40
41 Type JavaLangThreadGroup => Resolve(ref javaLangThreadGroup, "java.lang.ThreadGroup");
42
47 public object GetCurrent() => GetField(ref current, nameof(current)).GetValue();
48
53 public Thread GetNativeThread(object self) => GetField(ref nativeThread, nameof(nativeThread)).GetValue(self);
54
58 public object InvokeCurrentThread() => GetMethod(ref currentThread, nameof(currentThread), JavaLangThread).Invoker();
59
64 public bool InvokeIsInterrupted(object self) => GetMethod(ref isInterrupted, nameof(isInterrupted), typeof(bool)).Invoker(self);
65
71 public object Init(object threadGroup) => GetConstructor(ref init, JavaLangThreadGroup).Invoker(threadGroup);
72
78 public bool InvokeIsDaemon(object self) => GetMethod(ref isDaemon, nameof(isDaemon), typeof(bool)).Invoker(self);
79
83 public void InvokeDie(object self) => GetMethod(ref die, nameof(die), typeof(void)).Invoker(self);
84
88 public object InvokeGetThreadGroup(object self) => GetMethod(ref getThreadGroup, nameof(getThreadGroup), JavaLangThreadGroup).Invoker(self);
89
94 public bool InvokeInterrupted() => GetMethod(ref interrupted, nameof(interrupted), typeof(bool)).Invoker();
95
96 }
97
98#endif
99
100}
IKVM.Reflection.Type Type