Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Oglesbee A3 #30

wants to merge 3 commits into from

Conversation

lukeoglesbee
Copy link

Luke Oglesbee
38953581

Cheers!

@@ -28,6 +28,22 @@ defmodule Ex01 do
"""

def counter(value \\ 0) do
receive do
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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)
Copy link
Contributor

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.

-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants