-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 78dd334
Showing
7 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/ebin | ||
/deps | ||
erl_crash.dump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Finalizer | ||
|
||
** TODO: Add description ** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule Finalizer do | ||
defp receiver(fun) do | ||
fn -> | ||
receive do | ||
data -> fun.(data) | ||
end | ||
end | ||
end | ||
|
||
def define(data, fun) when is_function fun do | ||
:resource.notify_when_destroyed(spawn(receiver(fun)), data) | ||
end | ||
|
||
def define(data, pid) when is_pid pid do | ||
:resource.notify_when_destroyed(pid, data) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
defmodule Finalizer.Mixfile do | ||
use Mix.Project | ||
|
||
def project do | ||
[ app: :finalizer, | ||
version: "0.0.1", | ||
deps: deps ] | ||
end | ||
|
||
# Configuration for the OTP application | ||
def application do | ||
[] | ||
end | ||
|
||
# Returns the list of dependencies in the format: | ||
# { :foobar, "0.1", git: "https://github.com/elixir-lang/foobar.git" } | ||
defp deps do | ||
[ { :resource, %r(.*), github: "tonyrog/resource" } ] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[ "resource": {:git,"https://github.com/tonyrog/resource.git","37264ec960263cec0df8d6db0da818297b8d5771",[]} ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Code.require_file "../test_helper.exs", __FILE__ | ||
|
||
defmodule FinalizerTest do | ||
use ExUnit.Case | ||
|
||
test "the truth" do | ||
assert(true) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ExUnit.start |