Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Apr 23, 2013
0 parents commit 78dd334
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/ebin
/deps
erl_crash.dump
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Finalizer

** TODO: Add description **
17 changes: 17 additions & 0 deletions lib/finalizer.ex
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
20 changes: 20 additions & 0 deletions mix.exs
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
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[ "resource": {:git,"https://github.com/tonyrog/resource.git","37264ec960263cec0df8d6db0da818297b8d5771",[]} ]
9 changes: 9 additions & 0 deletions test/finalizer_test.exs
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
1 change: 1 addition & 0 deletions test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ExUnit.start

0 comments on commit 78dd334

Please sign in to comment.