Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Coroutines for Java  (Read 4667 times)
0 Members and 1 Guest are viewing this topic.
Offline MatthiasM

Junior Newbie





« Posted 2008-04-11 00:18:20 »

Hi,

I wrote a small (<10KB) library which adds Coroutines to Java Smiley

A article and the library itself can be found here

Ciao Matthias
Offline jezek2
« Reply #1 - Posted 2008-04-11 11:55:54 »

It's a very nice library, thanks for sharing. Smiley I've already integrated it into my engine for game code (and replaced JavaFlow that I used previously).
Offline brackeen

Junior Member





« Reply #2 - Posted 2008-04-11 19:52:53 »

Very interesting. So, I'm trying to grok it. What exactly does the preprocessing do? Can you show what happens to the TestIterator example?
Games published by our own members! Check 'em out!
Try the Free Demo of Droid Assault
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 437
Projects: 4


Hand over your head.


« Reply #3 - Posted 2008-04-11 20:30:44 »

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? Grin

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.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Offline MatthiasM

Junior Newbie





« Reply #4 - Posted 2008-04-12 01:46:15 »

Well Smiley

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
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (29 views)
2013-05-17 21:29:12

alaslipknot (39 views)
2013-05-16 21:24:48

gouessej (69 views)
2013-05-16 00:53:38

gouessej (68 views)
2013-05-16 00:17:58

theagentd (78 views)
2013-05-15 15:01:13

theagentd (72 views)
2013-05-15 15:00:54

StreetDoggy (113 views)
2013-05-14 15:56:26

kutucuk (136 views)
2013-05-12 17:10:36

kutucuk (136 views)
2013-05-12 15:36:09

UnluckyDevil (145 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.077 seconds with 20 queries.