-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Oglesbee A3 #30
base: master
Are you sure you want to change the base?
Oglesbee A3 #30
Conversation
@@ -28,6 +28,22 @@ defmodule Ex01 do | |||
""" | |||
|
|||
def counter(value \\ 0) do | |||
receive do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10, 10
@global_counter Ex02 | ||
|
||
def new_global_counter(value \\ 0) do | ||
{:ok, counter} = Agent.start_link(fn -> value end, name: @global_counter) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, you don't have to return the counter
pid here, but it doesn't hurt.
@@ -1,6 +1,26 @@ | |||
|
|||
defmodule Ex02 do | |||
|
|||
@global_counter Ex02 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
10*3
« your code here » | ||
# The max process count is one process per item in the collection | ||
# (Not very efficient, but it will work) | ||
safe_process_count = min(Enum.count(collection), process_count) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you're doing, but the spec explicitly says to divide the collection into n chunks, where n is the number of processors.
Luke Oglesbee
38953581
Cheers!