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

Side by Side Diff: common/chunkstream/chunkNode.go

Issue 1413923013: Add `chunk` segmented data library. (Closed) Base URL: https://github.com/luci/luci-go@logdog-review-streamserver
Patch Set: Use errors in pacnic. 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
« no previous file with comments | « common/chunkstream/chunk.go ('k') | common/chunkstream/chunk_test.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 chunkstream
6
7 import (
8 "sync"
9 )
10
11 var chunkNodePool = sync.Pool{
12 New: func() interface{} {
13 return &chunkNode{}
14 },
15 }
16
17 func newChunkNode(c Chunk) *chunkNode {
18 n := chunkNodePool.Get().(*chunkNode)
19 n.Chunk = c
20 return n
21 }
22
23 // chunkNode wraps a Chunk interface in a linked-list node.
24 type chunkNode struct {
25 Chunk
26
27 next *chunkNode
28 }
29
30 func (n *chunkNode) release() {
31 n.Chunk.Release()
32 n.Chunk = nil
33 n.next = nil
34 chunkNodePool.Put(n)
35 }
36
37 func (n *chunkNode) length() int {
38 return len(n.Bytes())
39 }
OLDNEW
« no previous file with comments | « common/chunkstream/chunk.go ('k') | common/chunkstream/chunk_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698