public class ReadableCounter
extends java.lang.Object
implements java.lang.AutoCloseable
Counter
.
Note:The user should call isClosed()
and ensure the result is false to avoid a race on reading a
closed counter.
Constructor and Description |
---|
ReadableCounter(org.agrona.concurrent.status.CountersReader countersReader,
int counterId)
Construct a view of an existing counter.
|
ReadableCounter(org.agrona.concurrent.status.CountersReader countersReader,
long registrationId,
int counterId)
Construct a view of an existing counter.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this counter.
|
int |
counterId()
Return the counter Id.
|
long |
get()
Get the latest value for the counter with volatile semantics.
|
long |
getWeak()
Get the value of the counter using weak ordering semantics.
|
boolean |
isClosed()
Has this counters been closed and should no longer be used?
|
java.lang.String |
label()
Return the counter label.
|
long |
registrationId()
Return the registration Id for the counter.
|
int |
state()
Return the state of the counter.
|
public ReadableCounter(org.agrona.concurrent.status.CountersReader countersReader, long registrationId, int counterId)
countersReader
- for getting access to the buffers.registrationId
- assigned by the driver for the counter or Aeron.NULL_VALUE
if not known.counterId
- for the counter to be viewed.java.lang.IllegalStateException
- if the id has for the counter has not been allocated.public ReadableCounter(org.agrona.concurrent.status.CountersReader countersReader, int counterId)
countersReader
- for getting access to the buffers.counterId
- for the counter to be viewed.java.lang.IllegalStateException
- if the id has for the counter has not been allocated.public long registrationId()
public int counterId()
public int state()
CountersReader.RECORD_ALLOCATED
,
CountersReader.RECORD_RECLAIMED
,
CountersReader.RECORD_UNUSED
public java.lang.String label()
public long get()
Note:The user should call isClosed()
and ensure the result is false to avoid a race on reading
a closed counter.
public long getWeak()
public void close()
Counter
it is viewing.close
in interface java.lang.AutoCloseable
public boolean isClosed()
Copyright © 2014-2018 Real Logic Ltd. All Rights Reserved.