+
Skip to content

Apply ExType #1

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

Merged
merged 1 commit into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@ When the process running `Ane.put` is interrupted (e.g. by `:erlang.exit(pid, :k
data could be generated if it finished insert operation but did not start delete operation. These
garbabge data could be removed by calling `Ane.clear` (periodically if it needs to handle constantly interruptions).

## Development Note

```sh
# type check with dialyzer
mix dialyzer

# type check with ex_type
mix type
```

## License

MIT
8 changes: 7 additions & 1 deletion lib/ane.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Ane do

@type atomics_ref() :: :atomics.atomics_ref()

@type tid() :: :ets.tid()
@type tid() :: :ets.tid() | atom()

@type t_for_ane_mode() :: {tid(), atomics_ref(), atomics_ref(), map()}

Expand Down Expand Up @@ -140,6 +140,8 @@ defmodule Ane do
end
end

@spec lookup(tid(), atomics_ref(), pos_integer(), integer()) :: {integer(), any()}

defp lookup(e, a2, i, version) do
case :ets.lookup(e, [i, version]) do
[{_, value}] ->
Expand Down Expand Up @@ -200,6 +202,8 @@ defmodule Ane do
:ok
end

@spec commit(tid(), atomics_ref(), pos_integer(), integer(), integer()) :: :ok

defp commit(e, a2, i, expected, desired) do
case :atomics.compare_exchange(a2, i, expected, desired) do
:ok ->
Expand Down Expand Up @@ -241,6 +245,8 @@ defmodule Ane do

def clear({_, _} = _ane), do: :ok

@spec clear_table(tid(), atomics_ref(), map(), any()) :: :ok

defp clear_table(_, _, _, :"$end_of_table"), do: :ok

defp clear_table(e, a2, cache, [i, version] = key) do
Expand Down
1 change: 1 addition & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ defmodule Ane.MixProject do
[
{:benchee, "~> 0.13", only: :dev},
{:ex_doc, "~> 0.19", only: :dev, runtime: false},
{:ex_type, "~> 0.2.1", only: :dev, runtime: true},
{:dialyxir, "~> 1.0.0-rc.4", only: :dev, runtime: false}
]
end
Expand Down
2 changes: 2 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"earmark": {:hex, :earmark, "1.3.1", "73812f447f7a42358d3ba79283cfa3075a7580a3a2ed457616d6517ac3738cb9", [:mix], [], "hexpm"},
"erlex": {:hex, :erlex, "0.1.6", "c01c889363168d3fdd23f4211647d8a34c0f9a21ec726762312e08e083f3d47e", [:mix], [], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.19.2", "6f4081ccd9ed081b6dc0bd5af97a41e87f5554de469e7d76025fba535180565f", [:mix], [{:earmark, "~> 1.2", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
"ex_type": {:hex, :ex_type, "0.2.1", "4ecc9f5cc416c687bbcae7b99033ab2a9498e2f32901988ed3c7c62d3d3312e9", [:mix], [{:ex_type_runtime, "~> 0.1.0", [hex: :ex_type_runtime, repo: "hexpm", optional: false]}], "hexpm"},
"ex_type_runtime": {:hex, :ex_type_runtime, "0.1.0", "c7557490c969aacaaada89b30213d3572b615b5ef29c6617f1b588b1213a5127", [:mix], [], "hexpm"},
"makeup": {:hex, :makeup, "0.7.0", "31ff28c5a4037380685415972ccb66ca157da5d87b2f3901c4cb31a7c0f21f40", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
"makeup_elixir": {:hex, :makeup_elixir, "0.12.0", "498c9c80c1ff84bc161440e7aa89458d2093090e774e9f235de54ce09a7d383a", [:mix], [{:makeup, "~> 0.7", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
"nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载