Skip to content

Commit

Permalink
Merge pull request #344 from grosser/grosser/read
Browse files Browse the repository at this point in the history
example for proc usage
  • Loading branch information
grosser authored Mar 24, 2024
2 parents 9322299 + 6668089 commit f66f105
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ Item: 4, Worker: 0
Item: 5, Worker: 1
```

### Dynamically generating jobs

Example: wait for work to arrive or sleep

```ruby
queue = []
Thread.new { loop { queue << rand(100); sleep 2 } } # job producer
Parallel.map(Proc.new { queue.pop }, in_processes: 3) { |f| f ? puts("#{f} received") : sleep(1) }
```

Tips
====

Expand Down

0 comments on commit f66f105

Please sign in to comment.