Fix perf regression by reverting https://gerrit.onosproject.org/#/c/3801/
Change-Id: Ia6930f53f1f7258a711b10ee648bc9024788117e
Showing
1 changed file
with
5 additions
and
8 deletions
| ... | @@ -19,16 +19,13 @@ import org.onosproject.core.IdBlock; | ... | @@ -19,16 +19,13 @@ import org.onosproject.core.IdBlock; |
| 19 | import org.onosproject.core.IdGenerator; | 19 | import org.onosproject.core.IdGenerator; |
| 20 | import org.onosproject.core.UnavailableIdException; | 20 | import org.onosproject.core.UnavailableIdException; |
| 21 | 21 | ||
| 22 | -import com.google.common.base.Supplier; | ||
| 23 | -import com.google.common.base.Suppliers; | ||
| 24 | - | ||
| 25 | /** | 22 | /** |
| 26 | * Base class of {@link IdGenerator} implementations which use {@link IdBlockAllocator} as | 23 | * Base class of {@link IdGenerator} implementations which use {@link IdBlockAllocator} as |
| 27 | * backend. | 24 | * backend. |
| 28 | */ | 25 | */ |
| 29 | public class BlockAllocatorBasedIdGenerator implements IdGenerator { | 26 | public class BlockAllocatorBasedIdGenerator implements IdGenerator { |
| 30 | protected final IdBlockAllocator allocator; | 27 | protected final IdBlockAllocator allocator; |
| 31 | - protected Supplier<IdBlock> idBlock; | 28 | + protected IdBlock idBlock; |
| 32 | 29 | ||
| 33 | /** | 30 | /** |
| 34 | * Constructs an ID generator which use {@link IdBlockAllocator} as backend. | 31 | * Constructs an ID generator which use {@link IdBlockAllocator} as backend. |
| ... | @@ -37,17 +34,17 @@ public class BlockAllocatorBasedIdGenerator implements IdGenerator { | ... | @@ -37,17 +34,17 @@ public class BlockAllocatorBasedIdGenerator implements IdGenerator { |
| 37 | */ | 34 | */ |
| 38 | protected BlockAllocatorBasedIdGenerator(IdBlockAllocator allocator) { | 35 | protected BlockAllocatorBasedIdGenerator(IdBlockAllocator allocator) { |
| 39 | this.allocator = allocator; | 36 | this.allocator = allocator; |
| 40 | - this.idBlock = Suppliers.memoize(allocator::allocateUniqueIdBlock); | 37 | + this.idBlock = allocator.allocateUniqueIdBlock(); |
| 41 | } | 38 | } |
| 42 | 39 | ||
| 43 | @Override | 40 | @Override |
| 44 | public long getNewId() { | 41 | public long getNewId() { |
| 45 | try { | 42 | try { |
| 46 | - return idBlock.get().getNextId(); | 43 | + return idBlock.getNextId(); |
| 47 | } catch (UnavailableIdException e) { | 44 | } catch (UnavailableIdException e) { |
| 48 | synchronized (allocator) { | 45 | synchronized (allocator) { |
| 49 | - idBlock = Suppliers.memoize(allocator::allocateUniqueIdBlock); | 46 | + idBlock = allocator.allocateUniqueIdBlock(); |
| 50 | - return idBlock.get().getNextId(); | 47 | + return idBlock.getNextId(); |
| 51 | } | 48 | } |
| 52 | } | 49 | } |
| 53 | } | 50 | } | ... | ... |
-
Please register or login to post a comment