-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from ksysoev/set_max_frame_size
Implements possibility to set max frame limit
- Loading branch information
Showing
3 changed files
with
74 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package channel | ||
|
||
import ( | ||
"bytes" | ||
"sync" | ||
) | ||
|
||
type bufferPool struct { | ||
pool *sync.Pool | ||
} | ||
|
||
func newBufferPool() *bufferPool { | ||
return &bufferPool{ | ||
pool: &sync.Pool{ | ||
New: func() interface{} { | ||
return &bytes.Buffer{} | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (p *bufferPool) get() *bytes.Buffer { | ||
return p.pool.Get().(*bytes.Buffer) | ||
} | ||
|
||
func (p *bufferPool) put(b *bytes.Buffer) { | ||
b.Reset() | ||
p.pool.Put(b) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters