aboutsummaryrefslogtreecommitdiff
path: root/usage_examples
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-07-07 21:49:23 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-07-07 21:49:48 +0200
commit91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff (patch)
treeda0a6611de67080689c030ae50bf99626ea139b2 /usage_examples
parent85fec0dffa5df13c0cafc86ca762774ba2c4d951 (diff)
downloadlombok-91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff.tar.gz
lombok-91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff.tar.bz2
lombok-91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff.zip
updated docs for new desugaring for getter(lazy=true)
Diffstat (limited to 'usage_examples')
-rw-r--r--usage_examples/GetterLazyExample_post.jpage19
1 files changed, 10 insertions, 9 deletions
diff --git a/usage_examples/GetterLazyExample_post.jpage b/usage_examples/GetterLazyExample_post.jpage
index 9f4b1ba3..afed1748 100644
--- a/usage_examples/GetterLazyExample_post.jpage
+++ b/usage_examples/GetterLazyExample_post.jpage
@@ -1,18 +1,19 @@
public class GetterLazyExample {
- private double[] $lombok$lazy1v;
- private volatile boolean $lombok$lazy1i;
- private final Object $lombok$lazyLock = new Object[0];
+ private final java.util.concurrent.AtomicReference<java.lang.Object> cached = new java.util.concurrent.AtomicReference<java.lang.Object>();
public double[] getCached() {
- if (!this.$lombok$lazy1i) {
- synchronized (this.$lombok$lazyLock) {
- if (!this.$lombok$lazy1i) {
- this.$lombok$lazy1v = expensive();
- this.$lombok$lazy1i = true;
+ java.lang.Object value = this.cached.get();
+ if (value == null) {
+ synchronized(value) {
+ value = this.cached.get();
+ if (value == null) {
+ final double[] actualValue = expensive();
+ value = actualValue == null ? this.cached : actualValue;
+ this.cached.set(value);
}
}
}
- return this.$lombok$lazy1v;
+ return (double[])(value == this.cached ? null : value);
}
private double[] expensive() {