Versions in this module Expand all Collapse all v0 v0.0.1 Feb 26, 2024 Changes in this version + var ErrNotImplemented = errors.New("this function is not supported by this implementation") + var ErrNotReady = errors.New("future is still pending") + func GetFirstResult[T any](ctx context.Context, coros ...Coroutine2[T]) (T, error) + func Sleep(ctx context.Context, duration time.Duration) error + func Wait(ctx context.Context, mode WaitMode, futs ...Futurer) error + func ZipLongest[T, U any, TI Iterable[T], UI Iterable[U]](it1 TI, it2 UI) iter.Seq2[T, U] + func Zip[T, U any, TI Iterable[T], UI Iterable[U]](it1 TI, it2 UI) iter.Seq2[T, U] + type AsyncIterable iter.Seq2[T, error] + func AsyncIter[T any](f func(yield func(T) error) error) AsyncIterable[T] + func (ai AsyncIterable[T]) ForEach(f func(T) error) error + func (ai AsyncIterable[T]) UntilErr(err *error) Iterator[T] + func (ai AsyncIterable[T]) YieldTo(yield func(T) error) error + type AsyncReadWriteCloser interface + WaitForReady func(ctx context.Context) error + type AsyncStream struct + func NewAsyncStream(file AsyncReadWriteCloser) *AsyncStream + func (a *AsyncStream) Chunks(ctx context.Context, chunkSize int) AsyncIterable[[]byte] + func (a *AsyncStream) Close() error + func (a *AsyncStream) Lines(ctx context.Context) AsyncIterable[[]byte] + func (a *AsyncStream) ReadAll(ctx context.Context) ([]byte, error) + func (a *AsyncStream) ReadChunk(ctx context.Context, chunkSize int) ([]byte, error) + func (a *AsyncStream) ReadLine(ctx context.Context) ([]byte, error) + func (a *AsyncStream) ReadUntil(ctx context.Context, character byte) ([]byte, error) + func (a *AsyncStream) Stream(ctx context.Context, bufSize int) AsyncIterable[[]byte] + func (a *AsyncStream) Write(ctx context.Context, data []byte) Awaitable[int] + type Awaitable interface + AddResultCallback func(callback func(result T, err error)) Awaitable[T] + Await func(ctx context.Context) (T, error) + Future func() *Future[T] + MustAwait func(ctx context.Context) T + Result func() (T, error) + Shield func() *Future[T] + WriteResultTo func(dst *T) Awaitable[T] + type Callback struct + func NewCallback(duration time.Duration, callback func()) *Callback + func (c *Callback) Cancel() bool + type ChannelFile struct — darwin/amd64, js/wasm, windows/amd64 + func (c *ChannelFile) WaitForReady(ctx context.Context) error + type ChannelPoller struct — darwin/amd64, js/wasm, windows/amd64 + func (c *ChannelPoller) Close() error + func (c *ChannelPoller) Dial(_ context.Context, _, _ string) (AsyncReadWriteCloser, error) + func (c *ChannelPoller) Pipe() (r, w AsyncReadWriteCloser, err error) + func (c *ChannelPoller) Subscribe(f channelNotifier) + func (c *ChannelPoller) Unsubscribe(f channelNotifier) + func (c *ChannelPoller) Wait(timeout time.Duration) error + func (c *ChannelPoller) WakeupThreadsafe() error + type ChannelReader struct — darwin/amd64, js/wasm, windows/amd64 + func NewChannelReader(poller *ChannelPoller, ch <-chan []byte) *ChannelReader + func (c *ChannelReader) Close() error + func (c *ChannelReader) Read(p []byte) (n int, err error) + func (c *ChannelReader) Write(p []byte) (n int, err error) + type ChannelWriter struct — darwin/amd64, js/wasm, windows/amd64 + func NewChannelWriter(poller *ChannelPoller, ch chan<- []byte) *ChannelWriter + func (c *ChannelWriter) Close() error + func (c *ChannelWriter) Read(p []byte) (n int, err error) + func (c *ChannelWriter) Write(p []byte) (n int, err error) + type Coroutine1 func(ctx context.Context) error + func (c Coroutine1) SpawnTask(ctx context.Context) *Task[any] + type Coroutine2 func(ctx context.Context) (R, error) + func (c Coroutine2[R]) SpawnTask(ctx context.Context) *Task[R] + type EpollAsyncFile struct — linux/amd64 + func NewEpollAsyncFile(poller *EpollPoller, f Fder) *EpollAsyncFile + func (eaf *EpollAsyncFile) Close() error + func (eaf *EpollAsyncFile) Fd() uintptr + func (eaf *EpollAsyncFile) Read(p []byte) (n int, err error) + func (eaf *EpollAsyncFile) WaitForReady(ctx context.Context) error + func (eaf *EpollAsyncFile) Write(p []byte) (n int, err error) + type EpollPoller struct — linux/amd64 + func (e *EpollPoller) Close() error + func (e *EpollPoller) Dial(ctx context.Context, network, address string) (conn AsyncReadWriteCloser, err error) + func (e *EpollPoller) Open(fd uintptr) (file AsyncReadWriteCloser, err error) + func (e *EpollPoller) Pipe() (r, w AsyncReadWriteCloser, err error) + func (e *EpollPoller) Subscribe(target *EpollAsyncFile) error + func (e *EpollPoller) Unsubscribe(target *EpollAsyncFile) error + func (e *EpollPoller) Wait(timeout time.Duration) error + func (e *EpollPoller) WakeupThreadsafe() error + type EpollSocket struct — linux/amd64 + func NewSocket(fd int) *EpollSocket + func (s *EpollSocket) Close() error + func (s *EpollSocket) Fd() uintptr + func (s *EpollSocket) Read(p []byte) (n int, err error) + func (s *EpollSocket) Write(p []byte) (n int, err error) + type EventLoop struct + func NewEventLoop() *EventLoop + func RunningLoop(ctx context.Context) *EventLoop + func RunningLoopMaybe(ctx context.Context) (loop *EventLoop, ok bool) + func (e *EventLoop) Dial(ctx context.Context, network, address string) (*AsyncStream, error) + func (e *EventLoop) DialLines(ctx context.Context, network, address string) AsyncIterable[[]byte] + func (e *EventLoop) Pipe() (r, w *AsyncStream, err error) + func (e *EventLoop) Run(ctx context.Context, main Coroutine1) error + func (e *EventLoop) RunCallback(callback func()) + func (e *EventLoop) RunCallbackThreadsafe(ctx context.Context, callback func()) + func (e *EventLoop) ScheduleCallback(delay time.Duration, callback func()) *Callback + func (e *EventLoop) WaitForCallbacks() *Future[any] + func (e *EventLoop) Yield(ctx context.Context, fut Futurer) error + type Fder interface — linux/amd64 + Fd func() uintptr + type Future struct + func Go[T any](ctx context.Context, f func(ctx context.Context) (T, error)) *Future[T] + func NewFuture[ResType any]() *Future[ResType] + func (f *Future[ResType]) AddDoneCallback(callback func(error)) Futurer + func (f *Future[ResType]) AddResultCallback(callback func(ResType, error)) Awaitable[ResType] + func (f *Future[ResType]) Await(ctx context.Context) (ResType, error) + func (f *Future[ResType]) Cancel(err error) + func (f *Future[ResType]) Err() error + func (f *Future[ResType]) Future() *Future[ResType] + func (f *Future[ResType]) HasResult() bool + func (f *Future[ResType]) MustAwait(ctx context.Context) ResType + func (f *Future[ResType]) Result() (ResType, error) + func (f *Future[ResType]) SetResult(result ResType, err error) + func (f *Future[ResType]) Shield() *Future[ResType] + func (f *Future[ResType]) WriteResultTo(dest *ResType) Awaitable[ResType] + type Futurer interface + AddDoneCallback func(callback func(error)) Futurer + Cancel func(err error) + Err func() error + HasResult func() bool + type Iterable interface + type Iterable2 interface + type Iterator iter.Seq[V] + func AsIterator[V any, VS []V](slice VS) Iterator[V] + func Chain[T any, TS Iterable[T]](its ...TS) Iterator[T] + func Count[T constraints.Integer](start T) Iterator[T] + func Filter[T, TS Iterable[T]](it TS, f func(T) bool) Iterator[T] + func FlatMap[T, U any, TS Iterable[T], US Iterable[U]](it TS, f func(T) US) Iterator[U] + func Flatten[T any, TS Iterable[T], TSS Iterable[TS]](its TSS) Iterator[T] + func Iter[V any, VI Iterable[V]](it VI) Iterator[V] + func Map[T, U any, TS Iterable[T]](it TS, f func(T) U) Iterator[U] + func Range[T constraints.Integer](count T) Iterator[T] + func Uniq[V comparable, VS Iterable[V]](it VS) Iterator[V] + func (i Iterator[V]) Collect() []V + type MapIterator iter.Seq2[K, V] + func AsIterator2[K comparable, V any](m map[K]V) MapIterator[K, V] + func Enumerate[T constraints.Integer, U any, UI Iterable[U]](start T, it UI) MapIterator[T, U] + func MapIter[K comparable, V any, I Iterable2[K, V]](it I) MapIterator[K, V] + func (mi MapIterator[K, V]) Collect() map[K]V + type Mutex struct + func (m *Mutex) Lock(ctx context.Context) error + func (m *Mutex) Unlock() + type Poller interface + Close func() error + Dial func(ctx context.Context, network, address string) (AsyncReadWriteCloser, error) + Pipe func() (r, w AsyncReadWriteCloser, err error) + Wait func(timeout time.Duration) error + WakeupThreadsafe func() error + func NewPoller() (Poller, error) + type Queue struct + func (q *Queue[T]) Get() *Future[T] + func (q *Queue[T]) Push(item T) + type Task struct + func SpawnTask[RetType any](ctx context.Context, coro Coroutine2[RetType]) *Task[RetType] + func (t *Task[RetType]) AddResultCallback(callback func(result RetType, err error)) Awaitable[RetType] + func (t *Task[RetType]) Await(ctx context.Context) (RetType, error) + func (t *Task[RetType]) Future() *Future[RetType] + func (t *Task[RetType]) MustAwait(ctx context.Context) RetType + func (t *Task[RetType]) Result() (RetType, error) + func (t *Task[RetType]) Shield() *Future[RetType] + func (t *Task[RetType]) WriteResultTo(dst *RetType) Awaitable[RetType] + func (t *Task[_]) AddDoneCallback(callback func(error)) Futurer + func (t *Task[_]) Cancel(err error) + func (t *Task[_]) Err() error + func (t *Task[_]) HasResult() bool + func (t *Task[_]) Stop() + type WaitMode int + const WaitAll + const WaitFirstError + const WaitFirstResult