Skip to content

Commit

Permalink
Godoc Optimization 📃💎
Browse files Browse the repository at this point in the history
  • Loading branch information
sherifabdlnaby committed Jan 8, 2019
1 parent e39ab5b commit b0a74ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
7 changes: 4 additions & 3 deletions gpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,9 @@ func BenchmarkBulkJobs_OverLimit(b *testing.B) {
// --------------------------------------

// --------------EXAMPLES----------------

// Example 1 - Simple Job Enqueue
func Example_suffixThree() {
func Example_one() {
concurrency := 2

// Create and start pool.
Expand Down Expand Up @@ -583,7 +584,7 @@ func Example_suffixThree() {
}

// Example 2 - Enqueue A Job with Timeout
func Example_suffixTwo() {
func Example_two() {
concurrency := 2

// Create and start pool.
Expand Down Expand Up @@ -622,7 +623,7 @@ func Example_suffixTwo() {
}

// Example 3 - Enqueue 10 Jobs and Stop pool mid-processing.
func Example_suffixOne() {
func Example_three() {
var pool Pool
pool = NewSemaphorePool(2)
log.Println("Starting Pool...")
Expand Down
20 changes: 10 additions & 10 deletions package.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// gpool is used to easily manages a resizeable pool of context aware goroutines to bound concurrency, A Job is Enqueued to the pool and only N jobs can be processing concurrently.
// Package gpool is used to easily manages a resizeable pool of context aware goroutines to bound concurrency, A Job is Enqueued to the pool and only N jobs can be processing concurrently.
//
// A Job is simply a func(){} When you Enqueue(ctx, func(){}) a job the call will return ONCE the job has started processing. Otherwise if the pool is full it will block until:
// 1. pool has room for the job.
// 2. job's context is canceled.
// 3. the pool is stopped.
// A Pool is either closed or started, the Pool will not accept any job unless pool.Start() is called.
// Stopping the Pool using pool.Stop() it will wait for all processing jobs to finish before returning, it will also unblock any blocked job enqueues (enqueues will return ErrPoolClosed).
// The Pool can be re-sized using Resize() that will resize the pool in a concurrent safe-way. Resize can enlarge the pool and any blocked enqueue will unblock after pool is resized, in case of shrinking the pool resize will not affect any already processing job.
// Enqueuing a Job will return error nil once a job starts, ErrPoolClosed if the pool is closed, or ErrJobCanceled if the job's context is canceled while blocking waiting for the pool.
// Start, Stop, and Resize(N) is all concurrent safe and can be called from multiple goroutines, subsequent calls of Start or Stop has no effect unless called interchangeably.
// A Job is simply a func(){} When you Enqueue(ctx, func(){}) a job the call will return ONCE the job has started processing. Otherwise if the pool is full it will block until:
// 1. pool has room for the job.
// 2. job's context is canceled.
// 3. the pool is stopped.
// A Pool is either closed or started, the Pool will not accept any job unless pool.Start() is called.
// Stopping the Pool using pool.Stop() it will wait for all processing jobs to finish before returning, it will also unblock any blocked job enqueues (enqueues will return ErrPoolClosed).
// The Pool can be re-sized using Resize() that will resize the pool in a concurrent safe-way. Resize can enlarge the pool and any blocked enqueue will unblock after pool is resized, in case of shrinking the pool resize will not affect any already processing job.
// Enqueuing a Job will return error nil once a job starts, ErrPoolClosed if the pool is closed, or ErrJobCanceled if the job's context is canceled while blocking waiting for the pool.
// Start, Stop, and Resize(N) is all concurrent safe and can be called from multiple goroutines, subsequent calls of Start or Stop has no effect unless called interchangeably.
package gpool

// Version gpool current interface version.
Expand Down

0 comments on commit b0a74ab

Please sign in to comment.