BasePool defines methods common to all pool types. Returns the number of tasks accepted by the pool that were canceled
before executing user code due to pool context cancellation. Returns the total number of tasks that have completed (either successfully or with an error).
Tasks accepted by the pool but canceled before execution are excluded. Returns the context associated with this pool. Returns the number of tasks that have been dropped because the queue was full. Returns the number of tasks that have completed with an error. Returns the maximum concurrency of the pool. Returns true if the pool is non-blocking, meaning that it will not block when the task queue is full.
In a non-blocking pool, tasks that cannot be submitted to the queue will be dropped.
By default, pools are blocking, meaning that they will block when the task queue is full. Returns the size of the task queue. Resizes the pool by changing the maximum concurrency (number of workers) of the pool.
The new max concurrency must be greater than 0.
If the new max concurrency is less than the current number of running workers, the pool will continue to run with the new max concurrency. Returns the number of worker goroutines that are currently active (executing a task) in the pool. Stops the pool and returns a future that can be used to wait for all tasks pending to complete.
The pool will not accept new tasks after it has been stopped. Stops the pool and waits for all tasks to complete. Returns true if the pool has been stopped or its context has been cancelled. Returns the total number of tasks submitted to the pool since its creation. Returns the number of tasks that have completed successfully. Returns the number of tasks that are currently waiting in the pool's queue.Pool(interface)ResultPool[...] (interface)
Represents a pool of goroutines that can execute tasks concurrently. Returns the number of tasks accepted by the pool that were canceled
before executing user code due to pool context cancellation. Returns the total number of tasks that have completed (either successfully or with an error).
Tasks accepted by the pool but canceled before execution are excluded. Returns the context associated with this pool. Returns the number of tasks that have been dropped because the queue was full. Returns the number of tasks that have completed with an error. Submits a task to the pool without waiting for it to complete.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, this method will return ErrPoolStopped. Returns the maximum concurrency of the pool. Creates a new task group. Creates a new task group with the specified context. Creates a new subpool with the specified maximum concurrency and options. Returns true if the pool is non-blocking, meaning that it will not block when the task queue is full.
In a non-blocking pool, tasks that cannot be submitted to the queue will be dropped.
By default, pools are blocking, meaning that they will block when the task queue is full. Returns the size of the task queue. Resizes the pool by changing the maximum concurrency (number of workers) of the pool.
The new max concurrency must be greater than 0.
If the new max concurrency is less than the current number of running workers, the pool will continue to run with the new max concurrency. Returns the number of worker goroutines that are currently active (executing a task) in the pool. Stops the pool and returns a future that can be used to wait for all tasks pending to complete.
The pool will not accept new tasks after it has been stopped. Stops the pool and waits for all tasks to complete. Returns true if the pool has been stopped or its context has been cancelled. Submits a task to the pool and returns a future that can be used to wait for the task to complete.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, the returned future will resolve to ErrPoolStopped. Submits a task to the pool and returns a future that can be used to wait for the task to complete.
The task function must return an error.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, the returned future will resolve to ErrPoolStopped. Returns the total number of tasks submitted to the pool since its creation. Returns the number of tasks that have completed successfully. Attempts to submit a task to the pool and returns a future that can be used to wait for the task to complete
and a boolean indicating whether the task was submitted successfully.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, the returned future will resolve to ErrPoolStopped. Attempts to submit a task to the pool and returns a future that can be used to wait for the task to complete
and a boolean indicating whether the task was submitted successfully.
The task function must return an error.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, the returned future will resolve to ErrPoolStopped. Returns the number of tasks that are currently waiting in the pool's queue.
Pool : BasePool[R]
func NewPool(maxConcurrency int, options ...Option) Pool
func NewSubpool(maxConcurrency int) Pool
func Pool.NewSubpool(maxConcurrency int, options ...Option) Pool
Type Parameters:
R: any Result is deprecated. Use ResultTask instead.
This interface is maintained for backward compatibility.
Deprecated: Use ResultTask instead. Done returns a channel that is closed when the task is complete or has failed. Wait waits for the task to complete and returns the result and any error that occurred.
Type Parameters:
R: any ResultPool is a pool that can be used to submit tasks that return a result. Returns the number of tasks accepted by the pool that were canceled
before executing user code due to pool context cancellation. Returns the total number of tasks that have completed (either successfully or with an error).
Tasks accepted by the pool but canceled before execution are excluded. Returns the context associated with this pool. Returns the number of tasks that have been dropped because the queue was full. Returns the number of tasks that have completed with an error. Returns the maximum concurrency of the pool. Creates a new task group. Creates a new task group with the specified context. Creates a new subpool with the specified maximum concurrency and options. Returns true if the pool is non-blocking, meaning that it will not block when the task queue is full.
In a non-blocking pool, tasks that cannot be submitted to the queue will be dropped.
By default, pools are blocking, meaning that they will block when the task queue is full. Returns the size of the task queue. Resizes the pool by changing the maximum concurrency (number of workers) of the pool.
The new max concurrency must be greater than 0.
If the new max concurrency is less than the current number of running workers, the pool will continue to run with the new max concurrency. Returns the number of worker goroutines that are currently active (executing a task) in the pool. Stops the pool and returns a future that can be used to wait for all tasks pending to complete.
The pool will not accept new tasks after it has been stopped. Stops the pool and waits for all tasks to complete. Returns true if the pool has been stopped or its context has been cancelled. Submits a task to the pool and returns a future that can be used to wait for the task to complete and get the result.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, this method will return ErrPoolStopped. Submits a task to the pool and returns a future that can be used to wait for the task to complete and get the result.
The task function must return a result and an error.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, this method will return ErrPoolStopped. Returns the total number of tasks submitted to the pool since its creation. Returns the number of tasks that have completed successfully. Attempts to submit a task to the pool and returns a future that can be used to wait for the task to complete
and a boolean indicating whether the task was submitted successfully.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, this method will return ErrPoolStopped. Attempts to submit a task to the pool and returns a future that can be used to wait for the task to complete
and a boolean indicating whether the task was submitted successfully.
The task function must return a result and an error.
The pool will not accept new tasks after it has been stopped.
If the pool has been stopped, this method will return ErrPoolStopped. Returns the number of tasks that are currently waiting in the pool's queue.
ResultPool : BasePool[R]
func NewResultPool[R](maxConcurrency int, options ...Option) ResultPool[R]
func ResultPool[R].NewSubpool(maxConcurrency int, options ...Option) ResultPool[R]
Type Parameters:
R: any ResultTask represents a task that yields a result. If the task fails, the error can be retrieved. Done returns a channel that is closed when the task is complete or has failed. Wait waits for the task to complete and returns the result and any error that occurred.
func ResultPool[R].Submit(task func() R) ResultTask[R]
func ResultPool[R].SubmitErr(task func() (R, error)) ResultTask[R]
func ResultPool[R].TrySubmit(task func() R) (ResultTask[R], bool)
func ResultPool[R].TrySubmitErr(task func() (R, error)) (ResultTask[R], bool)
Type Parameters:
O: any ResultTaskGroup represents a group of tasks that can be executed concurrently.
As opposed to TaskGroup, the tasks in a ResultTaskGroup yield a result.
The group can be waited on to block until all tasks have completed.
If any of the tasks return an error, the group will return the first error encountered. Returns a channel that is closed when all tasks in the group have completed, a task returns an error, or the group is stopped. Stops the group and cancels all remaining tasks. Running tasks are not interrupted. Submits a task to the group. Submits a task to the group that can return an error. Waits for all tasks in the group to complete and returns the results of each task in the order they were submitted.
If any of the tasks return an error, the group will return the first error encountered.
If the context is cancelled, the group will return the context error.
If the group is stopped, the group will return ErrGroupStopped.
If a task is running when the context is cancelled or the group is stopped, the task will be allowed to complete before returning.
func ResultPool[O].NewGroup() ResultTaskGroup[R]
func ResultPool[O].NewGroupContext(ctx context.Context) ResultTaskGroup[R]
func ResultTaskGroup[O].Submit(tasks ...func() O) ResultTaskGroup[O]
func ResultTaskGroup[O].SubmitErr(tasks ...func() (O, error)) ResultTaskGroup[O]
Task represents a task that can be waited on. If the task fails, the error can be retrieved. Done returns a channel that is closed when the task is complete or has failed. Wait waits for the task to complete and returns any error that occurred.TaskGroup(interface)
*github.com/alitto/pond/v2/internal/future.Future
func Submit(task func()) Task
func SubmitErr(task func() error) Task
func BasePool.Stop() Task
func Pool.Stop() Task
func Pool.Submit(task func()) Task
func Pool.SubmitErr(task func() error) Task
func Pool.TrySubmit(task func()) (Task, bool)
func Pool.TrySubmitErr(task func() error) (Task, bool)
func ResultPool.Stop() Task
TaskGroup represents a group of tasks that can be executed concurrently.
The group can be waited on to block until all tasks have completed.
If any of the tasks return an error, the group will return the first error encountered. Returns the context associated with this group.
This context will be cancelled when either the parent context is cancelled
or any task in the group returns an error, whichever comes first. Returns a channel that is closed when all tasks in the group have completed, a task returns an error, or the group is stopped. Stops the group and cancels all remaining tasks. Running tasks are not interrupted. Submits a task to the group. Submits a task to the group that can return an error. Waits for all tasks in the group to complete.
If any of the tasks return an error, the group will return the first error encountered.
If the context is cancelled, the group will return the context error.
If the group is stopped, the group will return ErrGroupStopped.
If a task is running when the context is cancelled or the group is stopped, the task will be allowed to complete before returning.
TaskGroup : Task
func NewGroup() TaskGroup
func Pool.NewGroup() TaskGroup
func Pool.NewGroupContext(ctx context.Context) TaskGroup
func TaskGroup.Submit(tasks ...func()) TaskGroup
func TaskGroup.SubmitErr(tasks ...func() error) TaskGroup
func github.com/pancsta/asyncmachine-go/pkg/helpers.Pool(ctx context.Context, limit int) TaskGroup
Package-Level Functions (total 10)
NewGroup creates a new task group with the default pool.
NewPool creates a new pool with the given maximum concurrency and options.
The new maximum concurrency must be greater than or equal to 0 (0 means no limit).
Type Parameters:
R: any NewResultPool creates a new result pool with the given maximum concurrency and options.
Result pools are generic pools that can be used to submit tasks that return a result.
The new maximum concurrency must be greater than or equal to 0 (0 means no limit).
NewSubpool creates a new subpool with the default pool.
Submit submits a task to the default pool and returns a future that can be used to wait for the task to complete.
SubmitErr submits a task to the default pool and returns a future that can be used to wait for the task to complete.
WithContext sets the context for the pool.
WithNonBlocking sets the pool to be non-blocking when the queue is full.
This option is only effective when the queue size is set.
WithoutPanicRecovery disables panic interception inside worker goroutines.
When this option is enabled, panics inside tasks will propagate just like regular goroutines.
WithQueueSize sets the max number of elements that can be queued in the pool.
The pages are generated with Goldsv0.8.4. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.