-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FIXED ASYNC NOT WORKING WHEN MAIN THREAD IS SLEEPING
- Loading branch information
1 parent
bd82646
commit 3387413
Showing
28 changed files
with
900 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package pisi.unitedmeows.yystal.clazz; | ||
|
||
import pisi.unitedmeows.yystal.parallel.Async; | ||
import pisi.unitedmeows.yystal.parallel.Promise; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class living<X> { | ||
|
||
private X value; | ||
private Promise promise; | ||
private Supplier<X> supplier; | ||
private final long interval; | ||
|
||
public living(X _value, long _interval) { | ||
interval = _interval; | ||
value = _value; | ||
promise = Async.async_loop_w(() -> value = supplier.get(), interval); | ||
} | ||
|
||
public living(long _interval) { | ||
interval = _interval; | ||
promise = Async.async_loop(() -> value = supplier.get(), interval); | ||
} | ||
|
||
public living<X> update(Supplier<X> _supplier) { | ||
supplier = _supplier; | ||
return this; | ||
} | ||
|
||
public living<X> pause() { | ||
promise.stop(); | ||
return this; | ||
} | ||
|
||
public living<X> resume() { | ||
promise = Async.async_loop_w(() -> value = supplier.get(), interval); | ||
return this; | ||
} | ||
|
||
|
||
public X get() { | ||
return value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.