forked from pyb1993/JavaRedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExpireFuture.java
More file actions
43 lines (34 loc) · 1.14 KB
/
ExpireFuture.java
File metadata and controls
43 lines (34 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package RedisFuture;
import Common.Logger;
import RedisDataBase.ExpireObject;
import RedisDataBase.PriorityList;
import RedisDataBase.RedisDb;
import RedisDataBase.RedisTimerWheel;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.concurrent.Future;
public class ExpireFuture implements RedisFuture{
public Future future;// 持有真正future的引用
int curIndex; // 持有的index
PriorityList[] expires;// 持有的hashMap
public ExpireFuture(int curIndex,PriorityList[] expires,Future future){
this.curIndex = curIndex;
this.expires = expires;
this.future = future;
}
// 注意到,toNormal必须要保证线程安全
public void onComplete(){
try{
RedisDb.RedisMap.toNormal();
RedisDb.ExpiresDict.toNormal();
RedisTimerWheel.convertTimerWheelToNormal(curIndex);
System.out.println("done ");
} catch (Exception e) {
Logger.debug(e.getStackTrace().toString());
}
}
public boolean isDone(){
return future.isDone();
}
public void get() throws Exception {future.get();}
}