| File | Date | Author | Commit |
|---|---|---|---|
| src | 2015-04-21 |
|
[01187e] Changing orbit-async to use orbit-agent-loader. |
| README.md | 2015-04-19 |
|
[18639d] Update README.md |
| pom.xml | 2015-04-21 |
|
[b712ce] Version 0.2.2. |
Orbit Async implements async-await methods in the JVM. It allows programmers to write asynchronous code in a sequential fashion. It was developed by BioWare, a division of Electronic Arts.
If you're looking for async await on the .NET CLR, see Asynchronous Programming with Async and Await.
Documentation is located here.
Orbit is licensed under the BSD 3-Clause License.
import com.ea.orbit.async.Await;
import static com.ea.orbit.async.Await.await;
public class Page
{
// has to be done at least once, usually in the main class.
static { Await.init(); }
public Task<Integer> getPageLength(URL url)
{
Task<String> pageTask = getPage(url);
// this will never block, it will return a promise
String page = await(pageTask);
return Task.fromValue(page.length());
}
}
Task<Integer> lenTask = getPageLength(new URL("http://example.com"));
System.out.println(lenTask.join());
import com.ea.orbit.async.Async;
import com.ea.orbit.async.Await;
import static com.ea.orbit.async.Await.await;
public class Page
{
// has to be done at least once, usually in the main class.
static { Await.init(); }
// must mark CompletableFuture methods with @Async
@Async
public CompletableFuture<Integer> getPageLength(URL url)
{
CompletableFuture<String> pageTask = getPage(url);
String page = await(pageTask);
return CompletableFuture.completedFuture(page.length());
}
}
CompletableFuture<Integer> lenTask = getPageLength(new URL("http://example.com"));
System.out.println(lenTask.join());