Skip to content

Commit

Permalink
Merge pull request #4 from danielberkompas/remove-unecessary-process
Browse files Browse the repository at this point in the history
Process calls in current process
  • Loading branch information
danielberkompas committed Sep 12, 2015
2 parents 0a0ca02 + 09d4191 commit 71fc03c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ progress from there. Existing calls will be looked up in an ETS table managed by

#### Under the Hood

- `CallProcessor.process/3` spins off a new process to do the actual call
processing for maximum concurrency.
- The current state of all ongoing calls is stored in the ETS table managed by
the `Telephonist.OngoingCall` process. See its docs for more details.

Expand Down
10 changes: 2 additions & 8 deletions lib/telephonist/call_processor.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
defmodule Telephonist.CallProcessor do
alias Telephonist.OngoingCall
import Task, only: [async: 1, await: 1]
import Telephonist.Event, only: [notify: 2]
import Telephonist.Format, only: [atomize_keys: 1]

Expand Down Expand Up @@ -45,13 +44,8 @@ defmodule Telephonist.CallProcessor do
def process(machine, twilio, options \\ %{}) do
twilio = atomize_keys(twilio)
notify :processing, {machine, twilio, options}

result = async fn ->
call = lookup(twilio)
do_processing(call, machine, twilio, options)
end

await result
call = lookup(twilio)
do_processing(call, machine, twilio, options)
end

defp lookup(twilio) do
Expand Down

0 comments on commit 71fc03c

Please sign in to comment.