Skip to content
This repository has been archived by the owner on Jun 21, 2018. It is now read-only.

Commit

Permalink
Migrate to rebar3
Browse files Browse the repository at this point in the history
  • Loading branch information
g-andrade committed May 1, 2017
1 parent ae0fecf commit 8afc226
Show file tree
Hide file tree
Showing 23 changed files with 211 additions and 182 deletions.
61 changes: 30 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,42 +1,41 @@
REBAR = $(shell command -v rebar || echo ./rebar)
DEPS_PLT=./.deps_plt
DEPS=erts kernel stdlib
REBAR3_URL=https://s3.amazonaws.com/rebar3/rebar3

.PHONY: all get-deps compile clean dialyze xref
ifeq ($(wildcard rebar3),rebar3)
REBAR3 = $(CURDIR)/rebar3
endif

all: get-deps compile
REBAR3 ?= $(shell test -e `which rebar3` 2>/dev/null && which rebar3 || echo "./rebar3")

get-deps:
@$(REBAR) get-deps
ifeq ($(REBAR3),)
REBAR3 = $(CURDIR)/rebar3
endif

compile:
@$(REBAR) compile
.PHONY: deps build clean dialyzer xref doc test publish

test: compile
$(REBAR) eunit skip_deps=true
all: build

build: $(REBAR3)
@$(REBAR3) compile

$(REBAR3):
wget $(REBAR3_URL) || curl -Lo rebar3 $(REBAR3_URL)
@chmod a+x rebar3

clean:
@$(REBAR) clean

$(DEPS_PLT):
@echo Building $(DEPS_PLT)
dialyzer --build_plt \
--output_plt $(DEPS_PLT) \
--apps $(DEPS)
#-r deps \
dialyze: compile $(DEPS_PLT)
dialyzer --fullpath \
--src src \
-Wunmatched_returns \
-Werror_handling \
-Wrace_conditions \
-Wunderspecs \
-r ebin \
--plt $(DEPS_PLT)
@$(REBAR3) clean

dialyzer:
@$(REBAR3) dialyzer

xref:
@$(REBAR) xref
@$(REBAR3) xref

doc: compile
test:
@$(REBAR3) eunit

doc: build
./scripts/hackish_inject_version_in_docs.sh
./scripts/hackish_make_docs.sh

publish:
@$(REBAR3) as publish hex publish
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

Copyright (c) 2016 Guilherme Andrade

__Version:__ 1.0.3
__Version:__ 1.0.3-1-gae0fecf

__Authors:__ Guilherme Andrade ([`nlocks(at)gandrade(dot)net`](mailto:nlocks(at)gandrade(dot)net)).

`nlocks`: Native spinlocks for Erlang


---------

An experiment on Erlang native spinlocks:
Expand All @@ -36,7 +37,6 @@ end,

### <a name="Brutal_kills_and_unreleased_locks">Brutal kills and unreleased locks</a> ###


Hackish solution. Other than setting up some sort of monitor in the Erlang land, I found no practical way to deal with these other than making use of _ownership_ objects, references to which should never leave the process under which they were created; the release therefore becomes dependent on the garbage collector calling their destructor, but this also makes it more convenient for regularly terminated processes that forget to clean up.


Expand Down Expand Up @@ -77,7 +77,6 @@ struct Lock {

### <a name="The_spinning">The spinning</a> ###


* It uses C++ 11 [compare_exchange_weak](http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange)
* For each attempt, a new NIF call is scheduled; this brings some overhead to the table but it's crucial to play nice with the VM
* If the timeout is other than 'infinity', for each attempt it compares the deadline against the current [steady_clock](http://en.cppreference.com/w/cpp/chrono/steady_clock) value; this feels excessive and might hurt performance.
Expand Down
2 changes: 1 addition & 1 deletion cpp_src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ endif

CXX=g++
RM=rm -f
INC=-I$(ERL_INCLUDE)
INC=
CPPFLAGS=-std=c++11 -Wall -Wextra -Wpedantic -fPIC -O2 $(INC)
LDLIBS=

Expand Down
5 changes: 2 additions & 3 deletions doc/utf8/README.md → doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

Copyright (c) 2016 Guilherme Andrade

__Version:__ 1.0.3
__Version:__ 1.0.3-1-gae0fecf

__Authors:__ Guilherme Andrade ([`nlocks(at)gandrade(dot)net`](mailto:nlocks(at)gandrade(dot)net)).

`nlocks`: Native spinlocks for Erlang

---------

An experiment on Erlang native spinlocks:
Expand All @@ -35,7 +36,6 @@ end,

### <a name="Brutal_kills_and_unreleased_locks">Brutal kills and unreleased locks</a> ###


Hackish solution. Other than setting up some sort of monitor in the Erlang land, I found no practical way to deal with these other than making use of _ownership_ objects, references to which should never leave the process under which they were created; the release therefore becomes dependent on the garbage collector calling their destructor, but this also makes it more convenient for regularly terminated processes that forget to clean up.


Expand Down Expand Up @@ -76,7 +76,6 @@ struct Lock {

### <a name="The_spinning">The spinning</a> ###


* It uses C++ 11 [compare_exchange_weak](http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange)
* For each attempt, a new NIF call is scheduled; this brings some overhead to the table but it's crucial to play nice with the VM
* If the timeout is other than 'infinity', for each attempt it compares the deadline against the current [steady_clock](http://en.cppreference.com/w/cpp/chrono/steady_clock) value; this feels excessive and might hurt performance.
Expand Down
2 changes: 1 addition & 1 deletion doc/edoc-info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
%% encoding: UTF-8
{packages,[]}.
{application,nlocks}.
{modules,[nlocks]}.
2 changes: 1 addition & 1 deletion doc/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Overview</title>
<title>The nlocks application</title>
</head>
<frameset cols="20%,80%">
<frame src="modules-frame.html" name="modulesFrame" title="">
Expand Down
2 changes: 1 addition & 1 deletion doc/modules-frame.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Overview</title>
<title>The nlocks application</title>
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="EDoc">
</head>
<body bgcolor="white">
Expand Down
2 changes: 1 addition & 1 deletion doc/nlocks.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ <h3 class="function"><a name="transaction-3">transaction/3</a></h3>
<hr>

<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Jun 12 2016, 19:29:27.</i></p>
<p><i>Generated by EDoc, May 1 2017, 02:07:22.</i></p>
</body>
</html>
46 changes: 7 additions & 39 deletions doc/nlocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* [Function Index](#index)
* [Function Details](#functions)



<a name="types"></a>

## Data Types ##
Expand All @@ -33,12 +31,10 @@ __abstract datatype__: `ownership()`
### <a name="type-trx_fun">trx_fun()</a> ###



<pre><code>
trx_fun() = fun(() -&gt; term())
</code></pre>


<a name="index"></a>

## Function Index ##
Expand All @@ -55,90 +51,62 @@ trx_fun() = fun(() -&gt; term())

### acquire_ownership/1 ###


<pre><code>
acquire_ownership(Lock::<a href="#type-lock">lock()</a>) -&gt; {ok, <a href="#type-ownership">ownership()</a>} | {error, timeout}
</code></pre>

<br></br>


<br />

<a name="acquire_ownership-2"></a>

### acquire_ownership/2 ###


<pre><code>
acquire_ownership(Lock::<a href="#type-lock">lock()</a>, Timeout::timeout()) -&gt; {ok, <a href="#type-ownership">ownership()</a>} | {error, timeout}
</code></pre>

<br></br>


<br />

<a name="info-0"></a>

### info/0 ###


<pre><code>
info() -&gt; [{allocated_locks | allocated_ownerships | acquired_locks | contention, non_neg_integer()} | {has_lockfree_counters | has_lockfree_ownership, boolean()}, ...]
</code></pre>

<br></br>


<br />

<a name="new-0"></a>

### new/0 ###


<pre><code>
new() -&gt; <a href="#type-lock">lock()</a>
</code></pre>

<br></br>


<br />

<a name="release_ownership-1"></a>

### release_ownership/1 ###


<pre><code>
release_ownership(Ownership::<a href="#type-ownership">ownership()</a>) -&gt; ok | {error, not_allowed} | {error, already_released}
</code></pre>

<br></br>


<br />

<a name="transaction-2"></a>

### transaction/2 ###


<pre><code>
transaction(Lock::<a href="#type-lock">lock()</a>, Fun::<a href="#type-trx_fun">trx_fun()</a>) -&gt; {ok, FunResult::term()} | {error, timeout}
</code></pre>

<br></br>


<br />

<a name="transaction-3"></a>

### transaction/3 ###


<pre><code>
transaction(Lock::<a href="#type-lock">lock()</a>, Fun::<a href="#type-trx_fun">trx_fun()</a>, Timeout::timeout()) -&gt; {ok, FunResult::term()} | {error, timeout}
</code></pre>

<br></br>


<br />

4 changes: 2 additions & 2 deletions doc/overview-summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div class="navbar"><a name="#navbar_top"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<h1>nlocks</h1>
<p>Copyright © 2016 Guilherme Andrade</p>
<p><b>Version:</b> 1.0.3</p>
<p><b>Version:</b> 1.0.3-1-gae0fecf</p>
<p><b>Authors:</b> Guilherme Andrade (<a href="mailto:nlocks(at)gandrade(dot)net"><tt>nlocks(at)gandrade(dot)net</tt></a>).</p>
<p><code>nlocks</code>: Native spinlocks for Erlang</p>

Expand Down Expand Up @@ -88,6 +88,6 @@ <h3><a name="Building">Building</a></h3>

<hr>
<div class="navbar"><a name="#navbar_bottom"></a><table width="100%" border="0" cellspacing="0" cellpadding="2" summary="navigation bar"><tr><td><a href="overview-summary.html" target="overviewFrame">Overview</a></td><td><a href="http://www.erlang.org/"><img src="erlang.png" align="right" border="0" alt="erlang logo"></a></td></tr></table></div>
<p><i>Generated by EDoc, Jun 12 2016, 19:29:27.</i></p>
<p><i>Generated by EDoc, May 1 2017, 02:07:22.</i></p>
</body>
</html>
2 changes: 1 addition & 1 deletion doc/overview.edoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@author Guilherme Andrade <nlocks(at)gandrade(dot)net>
@copyright 2016 Guilherme Andrade
@version 1.0.3
@version 1.0.3-1-gae0fecf
@title nlocks
@doc `nlocks': Native spinlocks for Erlang

Expand Down
11 changes: 0 additions & 11 deletions doc/packages-frame.html

This file was deleted.

4 changes: 2 additions & 2 deletions doc/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ div.spec {
margin-left: 2em;
background-color: #eeeeee;
}
a.module,a.package {
a.module {
text-decoration:none
}
a.module:hover,a.package:hover {
a.module:hover {
background-color: #eeeeee;
}
ul.definitions {
Expand Down
44 changes: 0 additions & 44 deletions mix.exs

This file was deleted.

Loading

0 comments on commit 8afc226

Please sign in to comment.