@@ -117,7 +117,6 @@ public final class PythonContext {
117
117
private volatile boolean finalizing ;
118
118
119
119
public static final class PythonThreadState {
120
- private final WeakReference <Thread > owner ;
121
120
private boolean shuttingDown = false ;
122
121
123
122
/*
@@ -138,7 +137,6 @@ public static final class PythonThreadState {
138
137
HashSet <Object > reprObjectSet ;
139
138
140
139
public PythonThreadState (@ SuppressWarnings ("unused" ) PythonContext context , Thread owner ) {
141
- this .owner = new WeakReference <>(owner );
142
140
}
143
141
144
142
void shutdown () {
@@ -149,14 +147,6 @@ boolean isShuttingDown() {
149
147
return shuttingDown ;
150
148
}
151
149
152
- boolean isOwner (Thread thread ) {
153
- return owner .get () == thread ;
154
- }
155
-
156
- WeakReference <Thread > getOwner () {
157
- return owner ;
158
- }
159
-
160
150
@ TruffleBoundary
161
151
boolean reprEnter (Object item ) {
162
152
if (reprObjectSet == null ) {
@@ -1104,11 +1094,8 @@ public void popCurrentImport() {
1104
1094
public Thread [] getThreads () {
1105
1095
CompilerAsserts .neverPartOfCompilation ();
1106
1096
Set <Thread > threads = new HashSet <>();
1107
- for (PythonThreadState ts : threadStateMapping .values ()) {
1108
- Thread th = ts .getOwner ().get ();
1109
- if (th != null ) {
1110
- threads .add (th );
1111
- }
1097
+ for (Thread th : threadStateMapping .keySet ()) {
1098
+ threads .add (th );
1112
1099
}
1113
1100
return threads .toArray (new Thread [0 ]);
1114
1101
}
@@ -1167,7 +1154,6 @@ public synchronized void disposeThread(Thread thread) {
1167
1154
// ts already removed, that is valid during context shutdown for daemon threads
1168
1155
return ;
1169
1156
}
1170
- assert ts .isOwner (thread ) : "thread state owner was changed before this thread was disposed!" ;
1171
1157
ts .shutdown ();
1172
1158
threadStateMapping .remove (thread );
1173
1159
releaseSentinelLock (ts .sentinelLock );
0 commit comments