| 289 | } |
| 290 | |
| 291 | private <K, V> List<Object> debugTake(Fiber<K, V> f) { |
| 292 | |
| 293 | Object o = null; |
| 294 | try { |
| 295 | |
| 296 | while (o == null) { |
| 297 | if (f.runner.isDone()) { |
| 298 | Object m = f.output.poll(); |
| 299 | if (m != null && m != NULL) |
| 300 | return Collections.singletonList(m); |
| 301 | else return Collections.emptyList(); |
| 302 | } |
| 303 | o = f.output.poll(1, TimeUnit.SECONDS); |
| 304 | if (o == null) { |
| 305 | System.out.println("---------------------------------------------------\n"); |
| 306 | System.out.println(" debugTake failed to get a result, we are hanging the main thread waiting on:"); |
| 307 | System.out.println(f + " " + f.debugDescription + " " + f.debugStatus); |
| 308 | System.out.println("---------------------------------------------------\n" + f.stopped + " " + f.runner + " " + f.runner.isCancelled() + " " + f.runner.isDone()); |
| 309 | System.out.println(" queues are :" + f.input.size() + " " + f.output.size()); |
| 310 | System.out.println(" meanwhile :"); |
| 311 | for (Fiber ll : live) { |
| 312 | System.out.println(ll + " " + ll.debugDescription + " " + ll.debugStatus + " " + ll.runner + " " + ll.runner.isDone() + " " + ll.runner.isCancelled() + " " + f.input.size() + " " + f.output.size()); |
| 313 | } |
| 314 | System.out.println("---------------------------------------------------\n"); |
| 315 | } |
| 316 | } |
| 317 | |
| 318 | ArrayList<Object> m = new ArrayList<>(f.output.size() + 1); |
| 319 | |
| 320 | m.add(o); |
| 321 | f.output.drainTo(m); |
| 322 | |
| 323 | return m; |
| 324 | } catch (InterruptedException e) { |
| 325 | e.printStackTrace(); |
| 326 | } |
| 327 | |
| 328 | return null; |
| 329 | } |
| 330 | |
| 331 | private void shutdown() throws InterruptedException { |
| 332 | for (Fiber f : live) { |