Skip to content

Commit

Permalink
feat: implement Linux 6.6 io-uring basic usages
Browse files Browse the repository at this point in the history
  • Loading branch information
hayabusa-cloud committed Sep 16, 2024
1 parent bf92009 commit 274ef0f
Show file tree
Hide file tree
Showing 7 changed files with 917 additions and 142 deletions.
7 changes: 7 additions & 0 deletions buffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,13 @@ func NewHugeBuffer() HugeBuffer { return HugeBuffer{} }
// NewGiantBuffer returns a new instance of GiantBuffer.
func NewGiantBuffer() GiantBuffer { return GiantBuffer{} }

// BufferType is an interface that represents different types of buffers, including
// PicoBuffer, NanoBuffer, MicroBuffer, SmallBuffer, MediumBuffer, LargeBuffer,
// HugeBuffer, and GiantBuffer. Each buffer type is a byte array with a specific size.
type BufferType interface {
PicoBuffer | NanoBuffer | MicroBuffer | SmallBuffer | MediumBuffer | LargeBuffer | HugeBuffer | GiantBuffer
}

// PicoBuffer represents a byte array with size of BufferSizePico
type PicoBuffer [BufferSizePico]byte

Expand Down
38 changes: 0 additions & 38 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,41 +58,3 @@ func ContextUserdata[T any](ctx context.Context) (ret T) {

return
}

type fdGetter interface {
getFD() (fd int)
}

type fdSetter interface {
setFD(fd int)
}

type fdCtx struct {
context.Context
fd int
}

func (ctx *fdCtx) getFD() (fd int) {
return ctx.fd
}

func (ctx *fdCtx) setFD(fd int) {
ctx.fd = fd
}

func contextWithFD(parent context.Context, fd int) context.Context {
if fdc, ok := parent.(fdSetter); ok {
fdc.setFD(fd)
return parent
}

return &fdCtx{Context: parent, fd: fd}
}

func contextFD(ctx context.Context) int {
if fdc, ok := ctx.(fdGetter); ok {
return fdc.getFD()
}

return -1
}
Loading

0 comments on commit 274ef0f

Please sign in to comment.