(Object o)
| 112 | } |
| 113 | |
| 114 | static public Object yield(Object o) throws InterruptedException, Stop { |
| 115 | if (fiber.get() == null) |
| 116 | throw new IllegalArgumentException(" yield called from non-fiber thread"); |
| 117 | |
| 118 | fiber.get().debugStatus = "yield from " + Arrays.asList(new Exception().getStackTrace()); |
| 119 | |
| 120 | if (fiber.get().stopped) throw new Stop(); |
| 121 | if (o == null) o = NULL; |
| 122 | |
| 123 | try { |
| 124 | fiber.get().output.put(o); |
| 125 | } catch (InterruptedException e) { |
| 126 | e.printStackTrace(); |
| 127 | } |
| 128 | |
| 129 | if (fiber.get().stopped) throw new Stop(); |
| 130 | |
| 131 | Object t = null; |
| 132 | try { |
| 133 | t = fiber.get().input.take(); |
| 134 | } catch (InterruptedException e) { |
| 135 | e.printStackTrace(); |
| 136 | try { |
| 137 | t = fiber.get().input.take(); |
| 138 | System.out.println(" recovered with :" + t); |
| 139 | } catch (InterruptedException e1) { |
| 140 | e1.printStackTrace(); |
| 141 | System.err.println(" -- giving up --"); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | if (fiber.get().stopped) throw new Stop(); |
| 146 | return t == NULL ? null : t; |
| 147 | } |
| 148 | |
| 149 | static public void leave(Object o) throws InterruptedException, Stop { |
| 150 | if (fiber.get() == null) |
no test coverage detected