Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(94)

Side by Side Diff: client/internal/logdog/butler/bundler/counter.go

Issue 1412063008: logdog: Add bundler library. (Closed) Base URL: https://github.com/luci/luci-go@logdog-review-streamserver
Patch Set: Updated from comments. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package bundler
6
7 import (
8 "sync/atomic"
9 )
10
11 // counter is a goroutine-safe monotonically-increasing counter.
12 type counter struct {
13 // current is the current counter value.
14 //
15 // It must be the first field in the struct to ensure it's 64-bit aligne d
16 // for atomic operations.
17 current int64
18 }
19
20 func (c *counter) next() int64 {
21 // AddInt64 returns the value + 1, so subtract one to get its previous v alue
22 // (current counter value).
23 return atomic.AddInt64(&c.current, 1) - 1
24 }
OLDNEW
« no previous file with comments | « client/internal/logdog/butler/bundler/bundler_test.go ('k') | client/internal/logdog/butler/bundler/data.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698