List of usage examples for java.util.concurrent.atomic AtomicInteger AtomicInteger
public AtomicInteger(int initialValue)
From source file:annis.gui.paging.PagingComponent.java
public PagingComponent(int count, int pageSize) { if (pageSize <= 0) { pageSize = 1;// w w w. jav a 2s. co m } if (count < 0) { count = 0; } currentPage = 1; this.count = new AtomicInteger(pageSize); this.pageSize = pageSize; setWidth("100%"); setHeight("-1px"); addStyleName("toolbar"); callbacks = new HashSet<>(); layout = new HorizontalLayout(); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, true, false, true)); setContent(layout); addStyleName(ChameleonTheme.PANEL_LIGHT); lblInfo = new Label(); lblInfo.setContentMode(ContentMode.HTML); lblInfo.addStyleName("right-aligned-text"); layout.setWidth("100%"); layout.setHeight("-1px"); btFirst = new Button(); btFirst.setIcon(FIRST); btFirst.setDescription("jump to first page"); btFirst.addClickListener((Button.ClickListener) this); btFirst.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btFirst.addStyleName(ChameleonTheme.BUTTON_SMALL); btFirst.setDisableOnClick(true); btLast = new Button(); btLast.setIcon(LAST); btLast.setDescription("jump to last page"); btLast.addClickListener((Button.ClickListener) this); btLast.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btLast.addStyleName(ChameleonTheme.BUTTON_SMALL); btLast.setDisableOnClick(true); btNext = new Button(); btNext.setIcon(RIGHT_ARROW); btNext.setDescription("jump to next page"); btNext.addClickListener((Button.ClickListener) this); btNext.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btNext.addStyleName(ChameleonTheme.BUTTON_SMALL); btNext.setDisableOnClick(true); btPrevious = new Button(); btPrevious.setIcon(LEFT_ARROW); btPrevious.setDescription("jump to previous page"); btPrevious.addClickListener((Button.ClickListener) this); btPrevious.addStyleName(ChameleonTheme.BUTTON_ICON_ONLY); btPrevious.addStyleName(ChameleonTheme.BUTTON_SMALL); btPrevious.setDisableOnClick(true); txtPage = new TextField(); txtPage.setDescription("current page"); txtPage.setHeight("-1px"); txtPage.setWidth(3.f, UNITS_EM); Validator pageValidator = new PageValidator("must be an integer greater than zero"); txtPage.addValidator(pageValidator); addActionHandler(new EnterHandler(txtPage)); lblMaxPages = new Label(); lblMaxPages.setDescription("maximal pages"); lblMaxPages.setSizeUndefined(); lblStatus = new Label(); lblStatus.setSizeUndefined(); layout.addComponent(btFirst); layout.addComponent(btPrevious); layout.addComponent(txtPage); layout.addComponent(lblMaxPages); layout.addComponent(btNext); layout.addComponent(btLast); layout.addComponent(lblStatus); layout.addComponent(lblInfo); layout.setComponentAlignment(btFirst, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(btPrevious, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(lblStatus, Alignment.MIDDLE_LEFT); layout.setComponentAlignment(lblMaxPages, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(txtPage, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(btNext, Alignment.MIDDLE_RIGHT); layout.setComponentAlignment(btLast, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(lblStatus, 1.0f); layout.setComponentAlignment(lblInfo, Alignment.MIDDLE_RIGHT); layout.setExpandRatio(lblInfo, 10.0f); update(false); }
From source file:io.mangoo.build.Watcher.java
@SuppressWarnings("all") public Watcher(Set<Path> watchDirectory, Set<String> includes, Set<String> excludes, Trigger trigger) throws IOException { this.watchService = FileSystems.getDefault().newWatchService(); this.watchKeys = new HashMap<>(); this.includes = includes; //NOSONAR this.excludes = excludes; //NOSONAR this.trigger = trigger; this.takeCount = new AtomicInteger(0); for (Path path : watchDirectory) { registerAll(path);/* w w w .java2s .com*/ } }
From source file:org.craftercms.core.cache.impl.CacheImpl.java
/** * Default constructor. Sets <code>timestampGenerator</code> to {@link org.craftercms.core.util.generators.impl * .IncrementalTimestampGenerator}.// w w w . j a va 2 s .c o m */ public CacheImpl() { ticks = new AtomicInteger(0); timestampGenerator = new IncrementalTimestampGenerator(); }
From source file:ca.psiphon.tunneledwebview.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mListView = (ListView) findViewById(R.id.listView); mWebView = (WebView) findViewById(R.id.webView); mLogMessages = new ArrayAdapter<String>(this, R.layout.log_message, R.id.logMessageTextView); mListView.setAdapter(mLogMessages);/*from www . j a v a 2s. com*/ mLocalHttpProxyPort = new AtomicInteger(0); mPsiphonTunnel = PsiphonTunnel.newPsiphonTunnel(this); }
From source file:com.intel.cosbench.driver.random.RangeIntGenerator.java
public RangeIntGenerator(int lower, int upper) { if (lower <= 0 || upper <= 0 || lower > upper) throw new IllegalArgumentException(); this.lower = lower; this.upper = upper; this.cursor = new AtomicInteger(0); }
From source file:com.intel.cosbench.controller.service.COSBControllerService.java
public void init() { if (this.context == null) { LOGGER.error("Controller Context is not initialized."); System.exit(-1);// w ww . j a va2s .co m } // initialize workload archiver and loader String archive_dir = context.getArchive_dir(); archiver = new SimpleWorkloadArchiver(archive_dir); loader = new SimpleWorkloadLoader(archive_dir); count = new AtomicInteger(archiver.getTotalWorkloads()); order = new AtomicInteger(0); processors = new HashMap<String, WorkloadProcessor>(); processors = Collections.synchronizedMap(processors); int concurrency = context.getConcurrency(); executor = new OrderThreadPoolExecutor(concurrency, concurrency, 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue<Runnable>(memRepo.getMaxCapacity(), new OrderFutureComparator())); }
From source file:org.jtheque.features.FeatureServiceTest.java
@Test public void listenerCalledForAddingFeature() { final AtomicInteger addCounter = new AtomicInteger(0); final AtomicInteger removeCounter = new AtomicInteger(0); final AtomicInteger modifyCounter = new AtomicInteger(0); featureService.addFeatureListener(new MyFeatureListener(addCounter, removeCounter, modifyCounter)); featureService.addMenu("no-module", new MenuNoMain()); assertEquals(0, addCounter.get());/* ww w . j a v a 2 s. c o m*/ assertEquals(0, removeCounter.get()); assertEquals(1, modifyCounter.get()); featureService.addMenu("no-module", new MenuNoMain()); assertEquals(0, addCounter.get()); assertEquals(0, removeCounter.get()); assertEquals(2, modifyCounter.get()); }
From source file:com.qiscus.sdk.presenter.QiscusChatPresenter.java
public QiscusChatPresenter(View view, QiscusChatRoom room) { super(view);/* w w w. j a va2 s . c o m*/ this.room = room; this.currentTopicId = room.getLastTopicId(); qiscusAccount = Qiscus.getQiscusAccount(); lastDeliveredCommentId = new AtomicInteger(0); lastReadCommentId = new AtomicInteger(0); updateReadState(); listenRoomEvent(); if (!EventBus.getDefault().isRegistered(this)) { EventBus.getDefault().register(this); } }
From source file:com.datatorrent.stram.security.StramWSFilter.java
@Override public void init(FilterConfig conf) throws ServletException { proxyHost = conf.getInitParameter(PROXY_HOST); tokenManager = new StramDelegationTokenManager(DELEGATION_KEY_UPDATE_INTERVAL, DELEGATION_TOKEN_MAX_LIFETIME, DELEGATION_TOKEN_RENEW_INTERVAL, DELEGATION_TOKEN_REMOVER_SCAN_INTERVAL); sequenceNumber = new AtomicInteger(0); try {//from w w w . j a v a 2s.c om UserGroupInformation ugi = UserGroupInformation.getLoginUser(); if (ugi != null) { loginUser = ugi.getUserName(); } tokenManager.startThreads(); } catch (IOException e) { throw new ServletException(e); } }
From source file:org.jtheque.file.FileServiceTest.java
@Test public void importers() { final AtomicInteger counter = new AtomicInteger(0); fileService.registerImporter("no-module", new Importer() { @Override//from w w w .jav a 2 s . c o m public boolean canImportFrom(String fileType) { return "xml".equals(fileType); } @Override public void importFrom(String path) throws FileException { assertEquals("path", path); counter.incrementAndGet(); } }); try { fileService.importDatas("no-module", "xml", "path"); } catch (FileException e) { fail("Exception during the export"); } assertEquals(1, counter.get()); }