Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 6f754f42 authored by Ludovic Le Frioux's avatar Ludovic Le Frioux
Browse files

Wrapper for PNCounter

parent 4d91f867
No related branches found
No related tags found
No related merge requests found
package client
import client.utils.CObjectUId
import crdtlib.crdt.PNCounter
class PNCounter(val oid: CObjectUId<PNCounter>, val readOnly: Boolean) :
CObject<PNCounter>(oid, readOnly) {
private val counterCrdt: PNCounter
get() = this.crdt as PNCounter
fun get(): Int {
this.beforeGetter()
val value = this.counterCrdt.get()
this.afterGetter()
return value
}
fun increment(amount: Int) {
val ts = this.beforeUpdate()
this.counterCrdt.increment(amount, ts)
this.afterUpdate()
}
fun decrement(amount: Int) {
val ts = this.beforeUpdate()
this.counterCrdt.decrement(amount, ts)
this.afterUpdate()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment