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

Method yield

src/main/java/field/app/ThreadSync.java:114–147  ·  view source on GitHub ↗
(Object o)

Source from the content-addressed store, hash-verified

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)

Callers 6

asMap_getMethod · 0.95
asMap_setMethod · 0.95
sendAndRespondMethod · 0.95
waitMethod · 0.95
inMainThreadMethod · 0.95

Calls 5

asListMethod · 0.80
takeMethod · 0.80
getMethod · 0.65
putMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected