package util
import "aqwari.net/net/styx/internal/util"
Package util contains internal routines used by the styx packages.
Index ¶
- func IsTempErr(err error) bool
- type BlackHole
- func (BlackHole) Close() error
- func (BlackHole) Read(p []byte) (int, error)
- func (BlackHole) Write(p []byte) (int, error)
- type RefCount
- type SectionWriter
Examples ¶
Functions ¶
func IsTempErr ¶
IsTempErr returns true if an error exports a Temporary() method that returns true.
Types ¶
type BlackHole ¶
type BlackHole struct{}
A BlackHole is an io.ReadWriteCloser that accepts an infinite amount of input and produces no output.
func (BlackHole) Close ¶
func (BlackHole) Read ¶
func (BlackHole) Write ¶
type RefCount ¶
type RefCount struct {
// contains filtered or unexported fields
}
A Refcount can be embedded in structures to provide
reference-counting of resources.
Code:play
Example¶
package main
import "aqwari.net/net/styx/internal/util"
type Session struct {
util.RefCount
User, Tree string
Requests chan []byte
}
func (s *Session) end() {
select {
case <-s.Requests:
return
}
}
func main() {
s := &Session{Requests: make(chan []byte)}
for i := 0; i < 10; i++ {
s.IncRef()
}
for i := 0; i < 20; i++ {
if !s.DecRef() {
s.end()
break
}
}
}
func (*RefCount) DecRef ¶
DecRef decrements refcount by 1. If the reference count has reached 0, DecRef will return false.
func (*RefCount) IncRef ¶
func (r *RefCount) IncRef()
IncRef increments refcount by 1. It is a run-time panic to create more than ^uint64(0) references.
type SectionWriter ¶
type SectionWriter struct {
// contains filtered or unexported fields
}
Section writer provides a partial analogue io.SectionReader, for writers.
func NewSectionWriter ¶
func NewSectionWriter(w io.WriterAt, off, n int64) *SectionWriter
func (*SectionWriter) Write ¶
func (s *SectionWriter) Write(p []byte) (int, error)
Source Files ¶
blackhole.go doc.go errors.go refcount.go sectionwriter.go
- Version
- v0.0.0-20221011015736-bf55d759d56b (latest)
- Published
- Oct 11, 2022
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 3 days ago –
Tools for package owners.