Skip to content

Commit

Permalink
Consistent definition of priority levels
Browse files Browse the repository at this point in the history
In the specs and the documentation of the spawn_opt family of functions
there is the following definition of priority levels:

	Level = low | normal | high

However, the process_flag/1 function in that module reads:

  process_flag(Flag :: priority, Level) -> OldLevel

    Types:

	Level = OldLevel = priority_level()
	priority_level() = low | normal | high | max

This is clearly inconsistent. Change specs to use the process_level()
type declaration instead of re-defining it in various places.
  • Loading branch information
kostis authored and rimmius committed Apr 4, 2013
1 parent b8e7276 commit 651d75a
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions erts/preloaded/src/erlang.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1905,11 +1905,11 @@ setelement(_Index, _Tuple1, _Value) ->
Function :: atom(),
Args :: [term()],
Options :: [Option],
Option :: link | monitor | {priority, Level}
Option :: link | monitor
| {priority, Level :: priority_level()}
| {fullsweep_after, Number :: non_neg_integer()}
| {min_heap_size, Size :: non_neg_integer()}
| {min_bin_vheap_size, VSize :: non_neg_integer()},
Level :: low | normal | high.
| {min_bin_vheap_size, VSize :: non_neg_integer()}.
spawn_opt(_Tuple) ->
erlang:nif_error(undefined).

Expand Down Expand Up @@ -2244,11 +2244,11 @@ spawn_monitor(M, F, A) ->
-spec spawn_opt(Fun, Options) -> pid() | {pid(), reference()} when
Fun :: function(),
Options :: [Option],
Option :: link | monitor | {priority, Level}
Option :: link | monitor
| {priority, Level :: priority_level()}
| {fullsweep_after, Number :: non_neg_integer()}
| {min_heap_size, Size :: non_neg_integer()}
| {min_bin_vheap_size, VSize :: non_neg_integer()},
Level :: low | normal | high.
| {min_bin_vheap_size, VSize :: non_neg_integer()}.
spawn_opt(F, O) when erlang:is_function(F) ->
spawn_opt(erlang, apply, [F, []], O);
spawn_opt({M,F}=MF, O) when erlang:is_atom(M), erlang:is_atom(F) ->
Expand All @@ -2262,11 +2262,11 @@ spawn_opt(F, O) ->
Node :: node(),
Fun :: function(),
Options :: [Option],
Option :: link | monitor | {priority, Level}
Option :: link | monitor
| {priority, Level :: priority_level()}
| {fullsweep_after, Number :: non_neg_integer()}
| {min_heap_size, Size :: non_neg_integer()}
| {min_bin_vheap_size, VSize :: non_neg_integer()},
Level :: low | normal | high.
| {min_bin_vheap_size, VSize :: non_neg_integer()}.
spawn_opt(N, F, O) when N =:= erlang:node() ->
spawn_opt(F, O);
spawn_opt(N, F, O) when erlang:is_function(F) ->
Expand Down Expand Up @@ -2354,11 +2354,11 @@ spawn_link(N,M,F,A) ->
Function :: atom(),
Args :: [term()],
Options :: [Option],
Option :: link | monitor | {priority, Level}
Option :: link | monitor
| {priority, Level :: priority_level()}
| {fullsweep_after, Number :: non_neg_integer()}
| {min_heap_size, Size :: non_neg_integer()}
| {min_bin_vheap_size, VSize :: non_neg_integer()},
Level :: low | normal | high.
| {min_bin_vheap_size, VSize :: non_neg_integer()}.
spawn_opt(M, F, A, Opts) ->
case catch erlang:spawn_opt({M,F,A,Opts}) of
{'EXIT',{Reason,_}} ->
Expand All @@ -2374,11 +2374,11 @@ spawn_opt(M, F, A, Opts) ->
Function :: atom(),
Args :: [term()],
Options :: [Option],
Option :: link | monitor | {priority, Level}
Option :: link | monitor
| {priority, Level :: priority_level()}
| {fullsweep_after, Number :: non_neg_integer()}
| {min_heap_size, Size :: non_neg_integer()}
| {min_bin_vheap_size, VSize :: non_neg_integer()},
Level :: low | normal | high.
| {min_bin_vheap_size, VSize :: non_neg_integer()}.
spawn_opt(N, M, F, A, O) when N =:= erlang:node(),
erlang:is_atom(M), erlang:is_atom(F),
erlang:is_list(A), erlang:is_list(O) ->
Expand Down

0 comments on commit 651d75a

Please sign in to comment.