in generators/ReliableStatefulService/templates/class/Service.java [36:51]
protected CompletableFuture<?> runAsync(CancellationToken cancellationToken) {
// TODO: Replace the following sample code with your own logic
// or remove this runAsync override if it's not needed in your service.
Transaction tx = stateManager.createTransaction();
CompletableFuture<ReliableHashMap<String, Long>> mapFuture = this.stateManager
.<String, Long>getOrAddReliableHashMapAsync("myHashMap");
return mapFuture.thenCompose((map) -> {
return computeValueAsync(map, tx, cancellationToken);
}).thenCompose((v) -> {
return commitTransaction(tx);
}).whenComplete((res, e) -> {
closeTransaction(tx);
});
}