Hi,
I wrote a small (<10KB) library which adds Coroutines to Java
A article and the library itself can be found here
Ciao Matthias
Hi,
I wrote a small (<10KB) library which adds Coroutines to Java
A article and the library itself can be found here
Ciao Matthias
Itās a very nice library, thanks for sharing. Iāve already integrated it into my engine for game code (and replaced JavaFlow that I used previously).
Very interesting. So, Iām trying to grok it. What exactly does the preprocessing do? Can you show what happens to the TestIterator example?
Isnāt this like software threading, with ābreakpointsā scattered through the bytecodes allowing you to suspend a method, do some other stuff and then continue where you left? Is it? ;D
Iām not too fond of something manipulating my bytecodes, but I guess in AI itās very convenient - my state machines often turn into a steaming pile.
Well
I could attach a javap dump of the example - which is long (at least too long for this forum) - but itās very easy to generate - after running the JUnit tests all class files have been instrumented.
The resulting code is similar to the āstandard Java exampleā on the website - except that the state is not stored as member variables - to allow for recursive calls - but instead in a thread local instance of the Stack class which is managed by the Coroutine class.
The bytecode gets more complex if you have exception handling using finally in your methods - even to the point where it will be impossible to write it using Java itself (without duplicating a lot of code).
Riven: Look at the possibilities that bytecode instrumentation offers ā¦
Ciao Matthias