core

package
v0.0.0-...-e31dbf6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2023-2024 antlabs. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	EAGAIN = syscall.EAGAIN
	EINTR  = syscall.EINTR
)

Variables

This section is empty.

Functions

func Accept

func Accept(network, addr string, e PollingApi) error

Accept 工具函数

func Close

func Close(fd int) error

func Dial

func Dial(network, addr string, e PollingApi) (fd int, err error)

dial 工具函数

func GetFdFromConn

func GetFdFromConn(c net.Conn) (newFd int, err error)

复制一份socket

func GetMaxFd

func GetMaxFd() int

func GetSendBufferSize

func GetSendBufferSize(fd int) (int, error)

func Read

func Read(fd int, p []byte) (n int, err error)

func SetNoDelay

func SetNoDelay(fd int, nodelay bool) error

func Write

func Write(fd int, p []byte) (n int, err error)

Types

type PollingApi

type PollingApi interface {
	AddRead(fd int) error
	AddWrite(fd int) error
	ResetRead(fd int) error
	DelRead(fd int) error
	Del(fd int) error
	Poll(tv time.Duration, cb func(int, State, error)) (retVal int, err error)
	Free()
	Name() string
}

func Create

func Create(triggerType TriggerType) (la PollingApi, err error)

创建epoll handler

type SafeConns

type SafeConns[T any] struct {
	// contains filtered or unexported fields
}

func (*SafeConns[T]) Add

func (s *SafeConns[T]) Add(fd int, c *T)

func (*SafeConns[T]) Del

func (s *SafeConns[T]) Del(fd int)

func (*SafeConns[T]) Get

func (s *SafeConns[T]) Get(fd int) *T

func (*SafeConns[T]) GetUnsafe

func (s *SafeConns[T]) GetUnsafe(fd int) *T

func (*SafeConns[T]) Init

func (s *SafeConns[T]) Init(max int)

func (*SafeConns[T]) UnsafeConns

func (s *SafeConns[T]) UnsafeConns() []*T

type State

type State uint32

枚举变量状态有可写,写读

const (
	// 可写
	WRITE State = 1 << iota
	// 可读
	READ
)

func (State) IsRead

func (s State) IsRead() bool

func (State) IsWrite

func (s State) IsWrite() bool

func (State) String

func (s State) String() string

type TriggerType

type TriggerType uint32

水平触发还是边缘触发

const (
	TriggerTypeLevel TriggerType = iota
	TriggerTypeEdge
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL