Documentation ¶
Index ¶
- Constants
- Variables
- func ClockGetTime(clockId ClockId) (*unix.Timespec, error)
- func MakeIpcSockpair(nonblock bool) (fds [2]int, err error)
- func Socket(domain, typ, proto int) (fd int, err error)
- func Spawn(exePath string, extraFd int) (*exec.Cmd, error)
- func TimerFdCreate(clockId ClockId, flags int) (int, error)
- func TimerFdGetTime(fd int, curr *ITimerSpec) error
- func TimerFdSetTime(fd int, flags int, new *ITimerSpec, old *ITimerSpec) error
- func WOULDBLOCK(err error) bool
- type BaseUserData
- type Bucket
- type BucketEntry
- type BufferedStream
- type BufferedStreamOnRead
- type ClockId
- type Epoll
- func (this *Epoll) AddFd(fd int, event uint32, watcher EventWatcher) error
- func (this *Epoll) Close() error
- func (this *Epoll) DelFd(fd int) error
- func (this *Epoll) ModFd(fd int, event uint32) error
- func (this *Epoll) Poll(msec int) error
- func (this *Epoll) WatcherCtl(action PollerAction, watcher EventWatcher) error
- type EventLoop
- type EventSizeType
- type EventWatcher
- type Fd
- type FdWatcher
- func (this *FdWatcher) Close() error
- func (this *FdWatcher) DisableRW() (update bool)
- func (this *FdWatcher) DisableRead() (update bool)
- func (this *FdWatcher) DisableWrite() (update bool)
- func (this *FdWatcher) GetEvent() EventSizeType
- func (this *FdWatcher) GetFd() int
- func (this *FdWatcher) Loop() EventLoop
- func (this *FdWatcher) SetEvent(event EventSizeType)
- func (this *FdWatcher) SetWatcher(watcher IOWatcher)
- func (this *FdWatcher) Start()
- func (this *FdWatcher) Update(inLoop bool)
- func (this *FdWatcher) WantRead() (update bool)
- func (this *FdWatcher) WantWrite() (update bool)
- type FdWatcherMap
- type GenericLoopNotify
- type IOEvtLoop
- type IOWatcher
- type ITimerSpec
- type Listener
- type ListenerOnAccept
- type LoopNotify
- type LoopNotifyBuilder
- type NotifyWatcher
- type Poller
- type PollerAction
- type PollerBuilder
- type SockFd
- func NewConnFd(addrS string) (SockFd, error)
- func NewConnFd2(version int, sockAddr unix.Sockaddr) (SockFd, error)
- func NewListenerFd(addrS string, backLog int, reuseAddr, reusePort bool) (SockFd, error)
- func NewListenerFd2(version int, sockAddr unix.Sockaddr, backLog int, reuseAddr, reusePort bool) (SockFd, error)
- func NewTcpSocketFd(version int, nonblock bool, cloexec bool) (SockFd, error)
- func (this SockFd) Accept(flags int) (nfd int, sa unix.Sockaddr, err error)
- func (this SockFd) Bind(sockAddr unix.Sockaddr) error
- func (this SockFd) Connect(addr unix.Sockaddr) error
- func (this SockFd) Listen(backLog int) error
- func (this SockFd) ReuseAddr(enable bool) error
- func (this SockFd) ReusePort(enable bool) error
- type SpinLock
- type Stream
- type StreamMode
- type StreamOnClose
- type StreamOnConnect
- type StreamOnRead
- type StreamWriter
- type SyscallSockAddr
- type TimeWheel
- type Timer
- type TimerOnTick
- type UnknownAFError
- type UserDataStorage
Constants ¶
View Source
const ( TmFdNonblock = unix.O_NONBLOCK TmFdCloexec = unix.O_CLOEXEC TmFdTimerAbstime = 1 << 0 )
View Source
const DefaultIOEvtLoopBufferSize = 1024 * 4
View Source
const MSG_NOSIGNAL = unix.MSG_NOSIGNAL
View Source
const Readable = unix.EPOLLIN
View Source
const Writeable = unix.EPOLLOUT
Variables ¶
View Source
var Debug = false
Functions ¶
func MakeIpcSockpair ¶
fd[0] for parent process fd[1] for child process nonblock : set socket nonblock
func TimerFdGetTime ¶
func TimerFdGetTime(fd int, curr *ITimerSpec) error
func TimerFdSetTime ¶
func TimerFdSetTime(fd int, flags int, new *ITimerSpec, old *ITimerSpec) error
func WOULDBLOCK ¶
Types ¶
type BaseUserData ¶
type BaseUserData struct {
// contains filtered or unexported fields
}
func (*BaseUserData) GetUserData ¶
func (this *BaseUserData) GetUserData() interface{}
func (*BaseUserData) SetUserData ¶
func (this *BaseUserData) SetUserData(data interface{})
type BucketEntry ¶
type BufferedStream ¶
type BufferedStream struct { *Stream // contains filtered or unexported fields }
func NewBufferedClientStream ¶
func NewBufferedClientStream(loop *IOEvtLoop, fd int, onRead BufferedStreamOnRead) *BufferedStream
func NewBufferedConnStream ¶
func NewBufferedConnStream(loop *IOEvtLoop, fd int, onRead BufferedStreamOnRead) *BufferedStream
type BufferedStreamOnRead ¶
type BufferedStreamOnRead func(sw StreamWriter, buf std.ReadableBuffer)
type ClockId ¶
type ClockId int
const ( ClockRealtime ClockId = unix.CLOCK_REALTIME ClockMonotonic ClockId = unix.CLOCK_MONOTONIC )
type Epoll ¶
type Epoll struct {
// contains filtered or unexported fields
}
func (*Epoll) WatcherCtl ¶
func (this *Epoll) WatcherCtl(action PollerAction, watcher EventWatcher) error
type EventLoop ¶
type EventLoop interface { io.Closer RunInLoop(cb func()) Notify() Run(ctx context.Context) Break() Poller() Poller }
func NewEventLoop ¶
func NewEventLoop2 ¶
func NewEventLoop2(poller Poller, builder LoopNotifyBuilder) (EventLoop, error)
type EventSizeType ¶
type EventSizeType = uint32
type EventWatcher ¶
type EventWatcher interface { io.Closer GetFd() int GetEvent() EventSizeType SetEvent(event EventSizeType) Update(inLoop bool) OnEvent(event EventSizeType) }
type FdWatcher ¶
type FdWatcher struct { BaseUserData // contains filtered or unexported fields }
func (*FdWatcher) DisableRead ¶
func (*FdWatcher) DisableWrite ¶
func (*FdWatcher) GetEvent ¶
func (this *FdWatcher) GetEvent() EventSizeType
func (*FdWatcher) SetEvent ¶
func (this *FdWatcher) SetEvent(event EventSizeType)
func (*FdWatcher) SetWatcher ¶
helper for driven class
type FdWatcherMap ¶
type FdWatcherMap struct {
// contains filtered or unexported fields
}
func NewFdWatcherMap ¶
func NewFdWatcherMap() *FdWatcherMap
func (*FdWatcherMap) Close ¶
func (this *FdWatcherMap) Close() error
func (*FdWatcherMap) GetWatcher ¶
func (this *FdWatcherMap) GetWatcher(fd int) EventWatcher
func (*FdWatcherMap) RmFd ¶
func (this *FdWatcherMap) RmFd(fd int)
func (*FdWatcherMap) SetFd ¶
func (this *FdWatcherMap) SetFd(fd int, watcher EventWatcher)
type GenericLoopNotify ¶
type GenericLoopNotify struct { *FdWatcher // contains filtered or unexported fields }
func (*GenericLoopNotify) Close ¶
func (this *GenericLoopNotify) Close() error
func (*GenericLoopNotify) GetEvent ¶
func (this *GenericLoopNotify) GetEvent() EventSizeType
func (*GenericLoopNotify) Notify ¶
func (this *GenericLoopNotify) Notify()
func (*GenericLoopNotify) OnEvent ¶
func (this *GenericLoopNotify) OnEvent(event EventSizeType)
func (*GenericLoopNotify) SetEvent ¶
func (this *GenericLoopNotify) SetEvent(event EventSizeType)
type IOEvtLoop ¶
type IOEvtLoop struct { EventLoop // contains filtered or unexported fields }
func NewIOEvtLoop ¶
type Listener ¶
type Listener struct { *FdWatcher // contains filtered or unexported fields }
func NewListener ¶
func NewListener(loop EventLoop, fd int, onAccept ListenerOnAccept) *Listener
func (*Listener) OnEvent ¶
func (this *Listener) OnEvent(event EventSizeType)
type ListenerOnAccept ¶
type LoopNotify ¶
type LoopNotify interface { EventWatcher Notify() }
func NewGenericLoopNotify ¶
func NewGenericLoopNotify(loop EventLoop, wakeupCb func()) (LoopNotify, error)
func NewNotifyWatcher ¶
func NewNotifyWatcher(loop EventLoop, wakeupCb func()) (LoopNotify, error)
type LoopNotifyBuilder ¶
type LoopNotifyBuilder func(EventLoop, func()) (LoopNotify, error)
var DefaultLoopNotifyCreator LoopNotifyBuilder
type NotifyWatcher ¶
type NotifyWatcher struct { *FdWatcher // contains filtered or unexported fields }
func (*NotifyWatcher) GetEvent ¶
func (this *NotifyWatcher) GetEvent() EventSizeType
func (*NotifyWatcher) Notify ¶
func (this *NotifyWatcher) Notify()
func (*NotifyWatcher) OnEvent ¶
func (this *NotifyWatcher) OnEvent(event EventSizeType)
func (*NotifyWatcher) SetEvent ¶
func (this *NotifyWatcher) SetEvent(event EventSizeType)
type Poller ¶
type Poller interface { io.Closer WatcherCtl(action PollerAction, watcher EventWatcher) error Poll(msec int) error }
type PollerBuilder ¶
var DefaultPollerCreator PollerBuilder
type SockFd ¶
type SockFd int
func NewListenerFd ¶
fd with nonblock, cloexec default
func NewListenerFd2 ¶
func NewListenerFd2(version int, sockAddr unix.Sockaddr, backLog int, reuseAddr, reusePort bool) (SockFd, error)
fd with nonblock, cloexec default
func NewTcpSocketFd ¶
create new socket , cloexec by default
type SpinLock ¶
type SpinLock struct {
// contains filtered or unexported fields
}
func NewLockedSpinLock ¶
func NewLockedSpinLock() *SpinLock
func NewSpinLock ¶
func NewSpinLock() *SpinLock
type Stream ¶
type Stream struct { *FdWatcher // contains filtered or unexported fields }
func NewClientStream ¶
func NewClientStream(loop *IOEvtLoop, fd int, rcb StreamOnRead) *Stream
func NewConnStream ¶
func NewConnStream(loop *IOEvtLoop, fd int, rcb StreamOnRead) *Stream
func (*Stream) Close ¶
it's safe to invoke Close multi times. ensure underlay resource has been cleanup
func (*Stream) OnEvent ¶
func (this *Stream) OnEvent(event EventSizeType)
func (*Stream) SetOnClose ¶
func (this *Stream) SetOnClose(cb StreamOnClose)
func (*Stream) SetOnConnect ¶
func (this *Stream) SetOnConnect(cb StreamOnConnect)
type StreamOnClose ¶
type StreamOnClose func(sw StreamWriter, err error)
type StreamOnConnect ¶
type StreamOnConnect func(sw StreamWriter, err error)
type StreamOnRead ¶
type StreamOnRead func(sw StreamWriter, data []byte, len int)
type StreamWriter ¶
type StreamWriter interface { io.Closer Write(data []byte, inLoop bool) UserDataStorage }
type SyscallSockAddr ¶
func ResolveTcpAddr ¶
func ResolveTcpAddr(addrS string) (*SyscallSockAddr, error)
type TimeWheel ¶
type TimeWheel struct {
// contains filtered or unexported fields
}
func NewTimeWheel ¶
func (*TimeWheel) Entries ¶
func (this *TimeWheel) Entries() chan<- BucketEntry
type Timer ¶
type Timer struct { *FdWatcher // contains filtered or unexported fields }
func NewTimerWatcher ¶
func NewTimerWatcher(loop EventLoop, clockId ClockId, onTick TimerOnTick) (*Timer, error)
func (*Timer) OnEvent ¶
func (this *Timer) OnEvent(event EventSizeType)
type TimerOnTick ¶
type TimerOnTick func(*Timer)
type UnknownAFError ¶
type UnknownAFError string
func (UnknownAFError) Error ¶
func (e UnknownAFError) Error() string
type UserDataStorage ¶
type UserDataStorage interface { GetUserData() interface{} SetUserData(interface{}) }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.