Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
otp: [21, 22, 23, 24, 25]
otp: [27, 28, 29]
fail-fast: false
container:
image: erlang:${{ matrix.otp }}
Expand Down
2 changes: 1 addition & 1 deletion ebin/gproc.app
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{registered,[]},
{included_applications,[]},
{applications,[stdlib,kernel]},
{vsn,"1.2.0"},
{vsn,"1.3.0"},
{modules,[gproc_eqc_tests,gproc,gproc_app,gproc_bcast,
gproc_dist,gproc_info,gproc_init,gproc_lib,
gproc_monitor,gproc_pool,gproc_ps,gproc_pt,gproc_sup,
Expand Down
4 changes: 2 additions & 2 deletions src/gproc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
%% @end

-module(gproc).
-vsn("1.2.0").
-vsn("1.3.0").
-behaviour(gen_server).

-export([start_link/0,
Expand Down Expand Up @@ -2282,7 +2282,7 @@ to_atom(S) ->
gproc_info(Pid, Pat) ->
Keys = ets:select(?TAB, [{ {{Pid,Pat}, '_'}, [], [{element,2,
{element,1,'$_'}}] }]),
{?MODULE, lists:zf(
{?MODULE, lists:filtermap(
fun(K) ->
try V = get_value(K, Pid),
{true, {K,V}}
Expand Down
2 changes: 1 addition & 1 deletion src/gproc_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
%%%----------------------------------------------------------------------

-module(gproc_app).
-vsn("1.2.0").
-vsn("1.3.0").

-behaviour(application).

Expand Down
2 changes: 1 addition & 1 deletion src/gproc_bcast.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
%% @end

-module(gproc_bcast).
-vsn("1.2.0").
-vsn("1.3.0").
-behaviour(gen_server).

-export([start_link/0,
Expand Down
2 changes: 1 addition & 1 deletion src/gproc_dist.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%% <p>For a detailed description, see gproc/doc/erlang07-wiger.pdf.</p>
%% @end
-module(gproc_dist).
-vsn("1.2.0").
-vsn("1.3.0").

%% -behaviour(gen_leader). % to avoid unnecessary warnings

Expand Down
2 changes: 1 addition & 1 deletion src/gproc_info.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%% @author Ulf Wiger <ulf@wiger.net>
%%
-module(gproc_info).
-vsn("1.2.0").
-vsn("1.3.0").

-export([i/0]).

Expand Down
2 changes: 1 addition & 1 deletion src/gproc_init.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%%%----------------------------------------------------------------------

-module(gproc_init).
-vsn("1.2.0").
-vsn("1.3.0").

%% API
-export([
Expand Down
20 changes: 13 additions & 7 deletions src/gproc_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%% <p>For a detailed description, see gproc/doc/erlang07-wiger.pdf.</p>
%% @end
-module(gproc_lib).
-vsn("1.2.0").
-vsn("1.3.0").

-export([await/3,
do_set_counter_value/3,
Expand Down Expand Up @@ -133,7 +133,8 @@ maybe_scan(_, _, _, _, _) ->

insert_attr({_,Scope,_} = Key, Attrs, Pid, Scope) when Scope==l;
Scope==g ->
case ets:lookup(?TAB, K = {Pid, Key}) of
K = {Pid, Key},
case ets:lookup(?TAB, K) of
[{_, Attrs0}] when is_list(Attrs) ->
As = proplists:get_value(attrs, Attrs0, []),
As1 = lists:foldl(fun({K1,_} = Attr, Acc) ->
Expand Down Expand Up @@ -487,16 +488,20 @@ unreg_opts(Key, Pid) ->
end.

remove_reg_1({c,_,_} = Key, Pid) ->
remove_counter_1(Key, ets:lookup_element(?TAB, Reg = {Key,Pid}, 3), Pid),
Reg = {Key,Pid},
remove_counter_1(Key, ets:lookup_element(?TAB, Reg, 3), Pid),
Reg;
remove_reg_1({r,_,_} = Key, Pid) ->
remove_resource_1(Key, ets:lookup_element(?TAB, Reg = {Key,Pid}, 3), Pid),
Reg = {Key,Pid},
remove_resource_1(Key, ets:lookup_element(?TAB, Reg, 3), Pid),
Reg;
remove_reg_1({T,_,_} = Key, _Pid) when T==a; T==n; T==rc ->
ets:delete(?TAB, Reg = {Key,T}),
Reg = {Key,T},
ets:delete(?TAB, Reg),
Reg;
remove_reg_1({_,_,_} = Key, Pid) ->
ets:delete(?TAB, Reg = {Key, Pid}),
Reg = {Key, Pid},
ets:delete(?TAB, Reg),
Reg.

remove_counter_1({c,C,N} = Key, Val, Pid) ->
Expand Down Expand Up @@ -605,7 +610,8 @@ update_resource_count_(C, N, Val) ->
end.

resource_count_zero(C, N) ->
case ets:lookup(?TAB, {K = {rc,C,N},rc}) of
K = {rc,C,N},
case ets:lookup(?TAB, {K, rc}) of
[{_, Pid, _}] ->
case get_attr(on_zero, Pid, K, undefined) of
undefined -> ok;
Expand Down
2 changes: 1 addition & 1 deletion src/gproc_monitor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
%% When a process subscribes to notifications for a given name, a message
%% will be sent each time that name is registered
-module(gproc_monitor).
-vsn("1.2.0").
-vsn("1.3.0").

-behaviour(gen_server).

Expand Down
8 changes: 5 additions & 3 deletions src/gproc_pool.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
%% jobs will not exceed the size of the pool.
%% @end
-module(gproc_pool).
-vsn("1.2.0").
-vsn("1.3.0").
-behavior(gen_server).

%% gproc round-robin name lookup
Expand Down Expand Up @@ -805,7 +805,8 @@ add_worker_(Pool, Name, Pos) ->
Pos.

reg_worker(Pool, Name, Pos) ->
gproc:reg_shared(Wrk = ?POOL_WRK(Pool, Name), 0),
Wrk = ?POOL_WRK(Pool, Name),
gproc:reg_shared(Wrk, 0),
gproc:set_attributes_shared(Wrk, [{n, Pos}]).

remove_worker_(Pool, Name) ->
Expand All @@ -825,7 +826,8 @@ do_remove_worker_(Pool, Name) ->
case AutoSize of
false -> ok;
true ->
case (NewLen = length(Ws1)) - length(Ws0) of
NewLen = length(Ws1),
case NewLen - length(Ws0) of
0 -> ok;
Diff when Diff < 0 ->
{_, Type} = gproc:get_value(K, shared),
Expand Down
2 changes: 1 addition & 1 deletion src/gproc_ps.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
%% @type status() = 1 | 0.
%% @end
-module(gproc_ps).
-vsn("1.2.0").
-vsn("1.3.0").

-export([subscribe/2,
subscribe_cond/3,
Expand Down
2 changes: 1 addition & 1 deletion src/gproc_pt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
%% @end
%%
-module(gproc_pt).
-vsn("1.2.0").
-vsn("1.3.0").

-export([parse_transform/2]).

Expand Down
2 changes: 1 addition & 1 deletion src/gproc_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
%%----------------------------------------------------------------------

-module(gproc_sup).
-vsn("1.2.0").
-vsn("1.3.0").

-behaviour(supervisor).

Expand Down
32 changes: 24 additions & 8 deletions test/gproc_test_lib.erl
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,35 @@ start_node(Name0) ->
{Name, _} = eunit_lib:split_node(Name0),
ensure_dist(),
{Pa, Pz} = paths(),
Paths = "-pa ./ -pz ../ebin" ++
lists:flatten([[" -pa " ++ Path || Path <- Pa],
[" -pz " ++ Path || Path <- Pz]]),
Args = "-kernel prevent_overlapping_partitions false " ++ Paths,
{ok, Node} = slave:start(host(), Name, Args),
Paths = lists:append([["-pa", "./", "-pz", "../ebin"]]
++ [["-pa", Path] || Path <- Pa]
++ [["-pz", Path] || Path <- Pz]),
Args = ["-kernel", "prevent_overlapping_partitions", "false" | Paths],
{ok, Pid, Node} = peer:start(#{ name => Name
, host => host_string()
, args => Args }),
save_controlling_pid(Node, Pid),
Node.

stop_nodes(Ns) ->
[stop_node(N) || N <- Ns],
ok.

stop_node(N) ->
slave:stop(N).
Pid = get_controlling_pid(N),
try peer:stop(Pid)
after
delete_controlling_pid(N)
end.

save_controlling_pid(Node, Pid) ->
persistent_term:put({?MODULE,peer_ref,Node}, Pid).

get_controlling_pid(Node) ->
persistent_term:get({?MODULE, peer_ref, Node}).

delete_controlling_pid(Node) ->
persistent_term:erase({?MODULE, peer_ref, Node}).

paths() ->
Path = code:get_path(),
Expand All @@ -72,8 +88,8 @@ paths() ->
{Pas, Pzs}.


host() ->
list_to_atom(host_string()).
%% host() ->
%% list_to_atom(host_string()).

host_string() ->
[_Name, Host] = re:split(atom_to_list(node()), "@", [{return, list}]),
Expand Down
4 changes: 2 additions & 2 deletions zomp.meta
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{name,"gproc"}.
{type,app}.
{modules,[]}.
{author,"Ulf Wiger"}.
{prefix,"gproc"}.
{author,"Ulf Wiger"}.
{desc,"Extended process registry for Erlang"}.
{package_id,{"uwiger","gproc",{1,2,0}}}.
{package_id,{"uwiger","gproc",{1,3,0}}}.
{deps,[]}.
{key_name,none}.
{a_email,"ulf@wiger.net"}.
Expand Down
Loading