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

Method service

src/main/java/field/app/ThreadSync2.kt:228–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

enterMainLoopMethod · 0.80

Calls 3

takeMethod · 0.80
removeMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected