/** * Create a new lease time map. */ public LeaseTimeMap(long leasetime, final ICommand<K> removecmd, boolean touchonread, boolean touchonwrite, IDelayRunner timer, boolean sync) { this.touchonread = touchonread; this.touchonwrite = touchonwrite; this.map = new HashMap<K, V>(); ICommand<K> rcmd = new ICommand<K>() { public void execute(K args) { // System.out.println("removed: "+args); LeaseTimeMap.this.map.remove(args); if(removecmd!=null) removecmd.execute(args); } }; this.times = LeaseTimeSet.createLeaseTimeCollection(leasetime, rcmd, timer, sync, this); }
/** * Add a new subscription. * @param future The subscription info. */ protected void addSubscribedTo(SubscriptionInfo info) { if(subscribedto==null) { subscribedto = LeaseTimeSet.createLeaseTimeCollection((long)(2.2*timelimit), new ICommand<SubscriptionInfo>() { public void execute(SubscriptionInfo entry) { System.out.println("Remove subscription of: "+entry.getPlatformId()); getRegistry().removeSubregistry(entry.getPlatformId()); } }, new AgentDelayRunner(component), false, null); } subscribedto.update(info); }
ILeaseTimeSet<Integer> col = createLeaseTimeCollection(3000);