| 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 | } |
no test coverage detected