Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/com/stuypulse/stuylib/streams/PollingIStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,23 @@ public PollingIStream(IStream stream, double dt) {
}

mResult = 0.0;
mPoller = new Notifier(() -> mResult = stream.get());
mPoller = new Notifier(() -> this.set(stream.get()));
mPoller.startPeriodic(dt);
}

public double get() {
private final synchronized void set(double result) {
mResult = result;
}

public final synchronized double get() {
return mResult;
}

protected void finalize() {
protected synchronized void finalize() {
close();
}

public void close() {
public synchronized void close() {
mPoller.close();
mResult = 0.0;
}
Expand Down
12 changes: 8 additions & 4 deletions src/com/stuypulse/stuylib/streams/angles/PollingAStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,23 @@ public PollingAStream(AStream stream, double dt) {
}

mResult = Angle.kNull;
mPoller = new Notifier(() -> mResult = stream.get());
mPoller = new Notifier(() -> this.set(stream.get()));
mPoller.startPeriodic(dt);
}

public Angle get() {
private final synchronized void set(Angle result) {
mResult = result;
}

public final synchronized Angle get() {
return mResult;
}

protected void finalize() {
protected synchronized void finalize() {
close();
}

public void close() {
public synchronized void close() {
mPoller.close();
mResult = Angle.kNull;
}
Expand Down
12 changes: 8 additions & 4 deletions src/com/stuypulse/stuylib/streams/booleans/PollingBStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,23 @@ public PollingBStream(BStream stream, double dt) {
}

mResult = false;
mPoller = new Notifier(() -> mResult = stream.get());
mPoller = new Notifier(() -> this.set(stream.get()));
mPoller.startPeriodic(dt);
}

public boolean get() {
private final synchronized void set(boolean result) {
mResult = result;
}

public final synchronized boolean get() {
return mResult;
}

protected void finalize() {
protected synchronized void finalize() {
close();
}

public void close() {
public synchronized void close() {
mPoller.close();
mResult = false;
}
Expand Down
12 changes: 8 additions & 4 deletions src/com/stuypulse/stuylib/streams/vectors/PollingVStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,23 @@ public PollingVStream(VStream stream, double dt) {
}

mResult = Vector2D.kOrigin;
mPoller = new Notifier(() -> mResult = stream.get());
mPoller = new Notifier(() -> this.set(stream.get()));
mPoller.startPeriodic(dt);
}

public Vector2D get() {
private final synchronized void set(Vector2D result) {
mResult = result;
}

public final synchronized Vector2D get() {
return mResult;
}

protected void finalize() {
protected synchronized void finalize() {
close();
}

public void close() {
public synchronized void close() {
mPoller.close();
mResult = Vector2D.kOrigin;
}
Expand Down