MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / launch

Method launch

src/main/java/field/app/ThreadSync2.kt:137–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135
136
137 @Volatile
138 @JvmField
139 var lastReturn: Any? = null;
140
141 @JvmOverloads
142 fun launch(license: Any?, r: Callable<*>, e: ExecutorService = executor) {
143 this.license = license
144 e.submit {
145 thisFibre.set(this)
146 thisThread = Thread.currentThread()
147
148// println(" \n\n\n\n THIS THREAD = $thisThread \n\n\n\n")
149
150 try {
151 lastReturn = r.call()
152
153 if (e is TrappedReturn)
154 e.notifyReturn(lastReturn)
155
156 while (serviceAlso(also))
157 yield()
158 } catch (t: TooLongKilledException) {
159 if (errorHandler != null)
160 errorHandler!!.accept(t)
161 } catch (t: KilledException) {
162
163 } catch (t: Throwable) {
164 System.err.println(" exception thrown in fibre '$debugText'")
165 t.printStackTrace()
166 if (errorHandler != null)
167 errorHandler!!.accept(t)
168 else {
169 }
170 }
171
172 finished = true
173 if (license != null)
174 output.put(license)
175
176 if (onExit != null) {
177 try {
178 onExit!!.run()
179 } catch (t: Throwable) {
180 System.err.println(" exception thrown in fibre's exit handler '$debugText'")
181 t.printStackTrace()
182 if (errorHandler != null)
183 errorHandler!!.accept(t)
184 else {
185 }
186 }
187 }
188
189 thisFibre.set(null)
190 }

Callers 1

launchAndServiceOnceMethod · 0.45

Calls 9

yieldFunction · 0.85
submitMethod · 0.80
setMethod · 0.65
acceptMethod · 0.65
callMethod · 0.45
notifyReturnMethod · 0.45
printlnMethod · 0.45
putMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected