| 226 | return ArrayList(current) |
| 227 | } |
| 228 | |
| 229 | @Volatile |
| 230 | internal var license: Any? = "-- license -- " |
| 231 | |
| 232 | fun service(): Boolean { |
| 233 | val didWork = current.size > 0 |
| 234 | |
| 235 | for (f in ArrayList(current)) { |
| 236 | if (f.paused) continue |
| 237 | |
| 238 | if (f.finished) |
| 239 | current.remove(f) |
| 240 | else { |
| 241 | val ll = license |
| 242 | license = null |
| 243 | |
| 244 | // f.input.put(ll) |
| 245 | |
| 246 | while (!f.input.offer(ll, 5, TimeUnit.SECONDS)) { |
| 247 | System.err.println(" waited 5 seconds to fibre $f from ${Thread.currentThread()}") |
| 248 | } |
| 249 | |
| 250 | license = f.output.take() |
| 251 | } |
| 252 | |
| 253 | if (f.pauseNext) { |
| 254 | f.pauseNext = false |
| 255 | f.paused = true |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | return didWork |
no test coverage detected