summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/CallbackPropertyOperator.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/CallbackPropertyOperator.java')
-rw-r--r--NET/worlds/scape/CallbackPropertyOperator.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/NET/worlds/scape/CallbackPropertyOperator.java b/NET/worlds/scape/CallbackPropertyOperator.java
new file mode 100644
index 0000000..55c2418
--- /dev/null
+++ b/NET/worlds/scape/CallbackPropertyOperator.java
@@ -0,0 +1,44 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Main;
+import NET.worlds.console.MainCallback;
+
+public class CallbackPropertyOperator implements MainCallback {
+ private Property prop;
+ private int func;
+ private Object value;
+ private boolean done;
+
+ CallbackPropertyOperator(Property prop, int func, Object value) {
+ this.prop = prop;
+ this.func = func;
+ this.value = value;
+
+ assert !Main.isMainThread();
+
+ Main.register(this);
+ }
+
+ synchronized Object getValue() {
+ while (!this.done) {
+ try {
+ this.wait();
+ } catch (InterruptedException var2) {
+ }
+ }
+
+ return this.value;
+ }
+
+ @Override
+ public synchronized void mainCallback() {
+ this.modify();
+ Main.unregister(this);
+ this.notify();
+ }
+
+ private void modify() {
+ this.value = this.prop.safeOperate(this.func, this.value);
+ this.done = true;
+ }
+}