MCPcopy Index your code
hub / github.com/jankotek/mapdb / Integer

Class Integer

src/main/java/org/mapdb/Atomic.java:109–320  ·  view source on GitHub ↗

An int record that may be updated atomically. An Atomic@Integer is used in applications such as atomically incremented counters, and cannot be used as a replacement for an java.lang.Integer. However, this class does extend Number to allow uniform access by tools and

Source from the content-addressed store, hash-verified

107 * deal with numerically-based classes.
108 */
109 public final static class Integer extends Number {
110
111 private static final long serialVersionUID = 4615119399830853054L;
112
113 protected final Store store;
114 protected final long recid;
115
116 public Integer(Store store, long recid) {
117 this.store = store;
118 this.recid = recid;
119 }
120
121 /**
122 * @return recid under which value is saved
123 */
124 public long getRecid(){
125 return recid;
126 }
127
128 /**
129 * Gets the current value.
130 *
131 * @return the current value
132 */
133 public final int get() {
134 return store.get(recid, Serializer.INTEGER);
135 }
136
137 /**
138 * Sets to the given value.
139 *
140 * @param newValue the new value
141 */
142 public final void set(int newValue) {
143 store.update(recid, newValue, Serializer.INTEGER);
144 }
145
146
147 /**
148 * Atomically sets to the given value and returns the old value.
149 *
150 * @param newValue the new value
151 * @return the previous value
152 */
153 public final int getAndSet(int newValue) {
154 //$DELAY$
155 for (;;) {
156 int current = get();
157 //$DELAY$
158 if (compareAndSet(current, newValue)) {
159 //$DELAY$
160 return current;
161 }
162 }
163 }
164
165 /**
166 * Atomically sets the value to the given updated value

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…