We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c66407d commit 5928530Copy full SHA for 5928530
ssg/methods.go
@@ -1513,6 +1513,19 @@ func (n *NumIdGenerator[T]) Set(current T) {
1513
n.current = current
1514
}
1515
1516
+// SafeSet method will set the current value to the given value
1517
+// if and only if the passed value is more than current value of
1518
+// the generator.
1519
+// please do notice that with calling n.Next() method, you will get
1520
+// the next id and not the current value.
1521
+func (n *NumIdGenerator[T]) SafeSet(current T) {
1522
+ n.mut.Lock()
1523
+ defer n.mut.Unlock()
1524
+ if current > n.current {
1525
+ n.current = current
1526
+ }
1527
+}
1528
+
1529
// Reset method will set the current value to 0.
1530
func (n *NumIdGenerator[T]) Reset() {
1531
n.mut.Lock()
0 commit comments