Andreas Wundsam | 73d7d67 | 2014-11-12 17:07:33 -0800 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.protocol; |
| 2 | |
| 3 | import java.util.concurrent.atomic.AtomicInteger; |
| 4 | |
| 5 | import org.projectfloodlight.openflow.types.BundleId; |
| 6 | |
| 7 | public class BundleIdGenerators { |
| 8 | private static final BundleIdGenerator GLOBAL_BUNDLE_ID_GENERATOR = create(); |
| 9 | |
| 10 | public static BundleIdGenerator create() { |
| 11 | return new StandardBundleIdGenerator(); |
| 12 | } |
| 13 | |
| 14 | public static BundleIdGenerator global() { |
| 15 | return GLOBAL_BUNDLE_ID_GENERATOR; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | class StandardBundleIdGenerator implements BundleIdGenerator { |
| 20 | |
| 21 | private final AtomicInteger idGen = new AtomicInteger(); |
| 22 | |
| 23 | @Override |
| 24 | public BundleId nextBundleId() { |
| 25 | return BundleId.of(idGen.incrementAndGet()); |
| 26 | } |
| 27 | |
| 28 | } |