-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In libqi, we can specify the "future callback type". This influences the execution of callbacks: if the type is Sync, then the callback is executed synchronously during setValue(…) or then(…)/andThen(…). Otherwise, it is executed asynchronously. For example: Promise<String> promise = new Promise<>(FutureCallbackType.Sync); System.out.println("#0"); promise.getFuture().andThen(new QiCallback<String>() { @OverRide public void onResult(String result) { // executed in the same thread System.out.println("#2"); } }); System.out.println("#1"); promise.setValue("hello"); System.out.println("#3"); This code sample prints: #0 #1 #2 #3 Change-Id: I732a76070a7ec67b58c1e666f0e538571689fede Reviewed-on: http://gerrit.aldebaran.lan/72640 Reviewed-by: rvimont <[email protected]> Tested-by: gerrit Reviewed-by: epinault <[email protected]>
- Loading branch information
Showing
5 changed files
with
59 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
qimessaging/src/main/java/com/aldebaran/qi/FutureCallbackType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.aldebaran.qi; | ||
|
||
public enum FutureCallbackType | ||
{ | ||
// keep values synchronized with qi::FutureCallbackType in libqi/qi/detail/future_fwd.hpp | ||
Sync(0), Async(1), Auto(2); | ||
|
||
int nativeValue; | ||
|
||
private FutureCallbackType(int nativeValue) | ||
{ | ||
this.nativeValue = nativeValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters