Advertisement
Guest User

Untitled

a guest
May 29th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.36 KB | None | 0 0
  1. public class MapStateMachine extends StateMachine {
  2.   private Map<Object, Object> map = new HashMap<>();
  3.  
  4.   public Object putWithTtl(Commit<PutWithTtl> commit) {
  5.     map.put(commit.operation().key, commit);
  6.     executor.schedule(Duration.ofMillis(commit.operation().ttl, () -> {
  7.       map.remove(commit.operation().key);
  8.       commit.release();
  9.     });
  10.   }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement