Skip to content

Commit c8b736b

Browse files
committed
replaced callbacks folder with lambda,
1 parent 0211f6d commit c8b736b

File tree

2 files changed

+17
-36
lines changed

2 files changed

+17
-36
lines changed

src/main/java/bgu/spl/mics/Callbacks/CPU_tick_callback.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

src/main/java/bgu/spl/mics/Future.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package bgu.spl.mics;
22

3+
import java.util.Timer;
34
import java.util.concurrent.TimeUnit;
45

56
/**
@@ -48,6 +49,8 @@ public T get() {
4849
public void resolve (T result) {
4950
this.result=result;
5051
isResolved=true;
52+
notifyAll();
53+
5154
}
5255

5356

@@ -74,7 +77,20 @@ public boolean isDone() {
7477
public T get(long timeout, TimeUnit unit) {
7578
//TODO: implement this.
7679
// TODO: add a timer on another thread and call regular get()
77-
return null;
80+
81+
long toWait=unit.toMicros(timeout);
82+
83+
if(isResolved)
84+
return result;
85+
86+
try {
87+
wait(toWait);
88+
} catch (InterruptedException e) {
89+
// TODO Auto-generated catch block
90+
e.printStackTrace();
91+
}
92+
93+
return result;
7894
}
7995

8096
}

0 commit comments

Comments
 (0)