Bläddra i källkod

ft: 优化更加高效的版本

master
SisMaker 1 år sedan
förälder
incheckning
e913e7c4cf
12 ändrade filer med 66 tillägg och 472 borttagningar
  1. +2
    -2
      README.md
  2. +0
    -20
      c_src/eGPidInt/eGPidInt.c
  3. +0
    -7
      c_src/eGPidInt/rebar.config
  4. +33
    -72
      c_src/eNifLock/eNifLock.cc
  5. +0
    -12
      include/eGLock.hrl
  6. +0
    -90
      src/eCLock.erl
  7. +1
    -2
      src/eGLock.app.src
  8. +30
    -163
      src/eGLock.erl
  9. +0
    -41
      src/eGLockMgr.erl
  10. +0
    -11
      src/eGLock_app.erl
  11. +0
    -26
      src/eGLock_sup.erl
  12. +0
    -26
      src/eGPidInt.erl

+ 2
- 2
README.md Visa fil

@ -11,5 +11,5 @@ Build
说明
----
eCLock 基于c++11 atomic
eGLock 基于c++11 atomic
其中要锁的key 不能是列表的字符串 原因是锁表的key会判断是否为list来区分是锁单key 还是锁列表

+ 0
- 20
c_src/eGPidInt/eGPidInt.c Visa fil

@ -1,20 +0,0 @@
#include "erl_nif.h"
static ERL_NIF_TERM pidToInt(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
ErlNifUInt64 TermInt = (ErlNifUInt64)argv[0];
return enif_make_uint64(env, TermInt);
}
static ERL_NIF_TERM intToPid(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) {
ErlNifUInt64 Pid;
if (!enif_get_uint64(env, argv[0], &Pid))
return enif_make_badarg(env);
return (ERL_NIF_TERM)Pid;
}
static ErlNifFunc nif_funcs[] = {
{"pidToInt", 1, pidToInt},
{"intToPid", 1, intToPid}
};
ERL_NIF_INIT(eGPidInt, nif_funcs, NULL, NULL, NULL, NULL);

+ 0
- 7
c_src/eGPidInt/rebar.config Visa fil

@ -1,7 +0,0 @@
{port_specs, [
{"../../priv/eGPidInt.so", ["*.c"]}
]}.

+ 33
- 72
c_src/eNifLock/eNifLock.cc Visa fil

@ -10,17 +10,14 @@ ERL_NIF_TERM atomTrue;
ERL_NIF_TERM atomFalse;
ERL_NIF_TERM atomUndefined;
typedef struct KeyNode_r
{
typedef struct KeyNode_r{
int KeyIx;
struct KeyNode_r *next;
} KeyNode;
bool isNotLocked(KeyNode *LockedHead, int KeyIx)
{
bool isNotLocked(KeyNode *LockedHead, int KeyIx){
KeyNode *temp = LockedHead;
while (temp != NULL)
{
while (temp != NULL){
if (temp->KeyIx == KeyIx)
return false;
temp = temp->next;
@ -28,46 +25,33 @@ bool isNotLocked(KeyNode *LockedHead, int KeyIx)
return true;
}
int nifLoad(ErlNifEnv *env, void **priv_data, ERL_NIF_TERM)
{
int nifLoad(ErlNifEnv *env, void **priv_data, ERL_NIF_TERM){
atomTrue = enif_make_atom(env, "true");
atomFalse = enif_make_atom(env, "false");
atomUndefined = enif_make_atom(env, "undefined");
return 0;
}
bool lockOne(ErlNifEnv *env, ErlNifPid *ThePid, int KeyIx, uint64_t Val)
{
bool lockOne(ErlNifEnv *env, ErlNifPid *ThePid, int KeyIx, uint64_t Val){
uint64_t Expected = 0;
if (LockSlot[KeyIx].compare_exchange_strong(Expected, Val))
{
if (LockSlot[KeyIx].compare_exchange_strong(Expected, Val)){
return true;
}
else
{
}else{
ThePid->pid = (ERL_NIF_TERM)Expected;
if (enif_is_process_alive(env, ThePid))
{
if (enif_is_process_alive(env, ThePid)){
return false;
}
else
{
if (LockSlot[KeyIx].compare_exchange_strong(Expected, Val))
{
}else{
if (LockSlot[KeyIx].compare_exchange_strong(Expected, Val)){
return true;
}
else
{
}else{
return false;
}
}
}
}
ERL_NIF_TERM tryLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
{
if (enif_is_list(env, argv[0]))
{
ERL_NIF_TERM tryLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[]){
if (enif_is_list(env, argv[0])){
ERL_NIF_TERM allList = argv[0];
ERL_NIF_TERM head;
ErlNifPid ThePid;
@ -75,22 +59,16 @@ ERL_NIF_TERM tryLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
uint64_t Val = (uint64_t)(ThePid.pid);
int KeyIx;
KeyNode *LockedHead = NULL;
while (enif_get_list_cell(env, allList, &head, &allList))
{
while (enif_get_list_cell(env, allList, &head, &allList)){
KeyIx = enif_hash(ERL_NIF_INTERNAL_HASH, head, HashSalt) % LockSize;
KeyNode OneKeyNode = {KeyIx, LockedHead};
if (isNotLocked(LockedHead, KeyIx))
{
if (lockOne(env, &ThePid, KeyIx, Val))
{
if (isNotLocked(LockedHead, KeyIx)){
if (lockOne(env, &ThePid, KeyIx, Val)){
LockedHead = &OneKeyNode;
}
else
{
}else{
uint64_t RExpected;
KeyNode *temp = LockedHead;
while (temp != NULL)
{
while (temp != NULL){
RExpected = Val;
LockSlot[temp->KeyIx].compare_exchange_strong(RExpected, 0);
temp = temp->next;
@ -99,30 +77,23 @@ ERL_NIF_TERM tryLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
}
}
return atomTrue;
}
else
{
}else{
int KeyIx;
KeyIx = enif_hash(ERL_NIF_INTERNAL_HASH, argv[0], HashSalt) % LockSize;
ErlNifPid ThePid;
enif_self(env, &ThePid);
uint64_t Val = (uint64_t)(ThePid.pid);
if (lockOne(env, &ThePid, KeyIx, Val))
{
if (lockOne(env, &ThePid, KeyIx, Val)){
return atomTrue;
}
else
{
}else{
return atomFalse;
}
}
}
ERL_NIF_TERM releaseLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
{
if (enif_is_list(env, argv[0]))
{
ERL_NIF_TERM releaseLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[]){
if (enif_is_list(env, argv[0])){
ERL_NIF_TERM allList = argv[0];
ERL_NIF_TERM head;
ErlNifPid ThePid;
@ -132,50 +103,39 @@ ERL_NIF_TERM releaseLock(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
int KeyIx;
int isAllOk = 1;
while (enif_get_list_cell(env, allList, &head, &allList))
{
while (enif_get_list_cell(env, allList, &head, &allList)){
KeyIx = enif_hash(ERL_NIF_INTERNAL_HASH, head, HashSalt) % LockSize;
RExpected = Expected;
if (!LockSlot[KeyIx].compare_exchange_strong(RExpected, 0))
{
if (!LockSlot[KeyIx].compare_exchange_strong(RExpected, 0)){
isAllOk = 0;
}
}
return isAllOk > 0 ? atomTrue : atomFalse;
}
else
{
}else{
int KeyIx;
KeyIx = enif_hash(ERL_NIF_INTERNAL_HASH, argv[0], HashSalt) % LockSize;
ErlNifPid ThePid;
enif_self(env, &ThePid);
uint64_t Expected = (uint64_t)(ThePid.pid);
if (LockSlot[KeyIx].compare_exchange_strong(Expected, 0))
{
if (LockSlot[KeyIx].compare_exchange_strong(Expected, 0)){
return atomTrue;
}
else
{
}else{
return atomFalse;
}
}
}
ERL_NIF_TERM getLockPid(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
{
ERL_NIF_TERM getLockPid(ErlNifEnv *env, int, const ERL_NIF_TERM argv[]){
int KeyIx;
KeyIx = enif_hash(ERL_NIF_INTERNAL_HASH, argv[0], HashSalt) % LockSize;
ErlNifPid ThePid;
uint64_t Var = LockSlot[KeyIx].load();
if (Var > 0)
{
if (Var > 0){
ThePid.pid = (ERL_NIF_TERM)Var;
return enif_make_pid(env, &ThePid);
}
else
{
}else{
return atomUndefined;
}
}
@ -183,6 +143,7 @@ ERL_NIF_TERM getLockPid(ErlNifEnv *env, int, const ERL_NIF_TERM argv[])
static ErlNifFunc nifFuncs[] = {
{"tryLock", 1, tryLock},
{"releaseLock", 1, releaseLock},
{"getLockPid", 1, getLockPid}};
{"getLockPid", 1, getLockPid}
};
ERL_NIF_INIT(eNifLock, nifFuncs, &nifLoad, NULL, NULL, NULL)

+ 0
- 12
include/eGLock.hrl Visa fil

@ -1,12 +0,0 @@
%% :Ms
-define(LockTimeOut, 5000).
%% :Ms
-define(ReTryTime, 3).
%%
-define(eGLockBatch, 15).
%%
-define(eGLockSize, 2097152).
%% atomics索引
-define(eGLockRef, eGLockRef).

+ 0
- 90
src/eCLock.erl Visa fil

@ -1,90 +0,0 @@
-module(eCLock).
-define(CASE(Cond, Then, That), case Cond of true -> Then; _ -> That end).
%% :Ms
-define(LockTimeOut, 5000).
%% :Ms
-define(ReTryTime, 3).
-export([
tryLock/1
, tryLock/2
, releaseLock/1
, getLockPid/1
, lockApply/2
, lockApply/3
]).
-spec tryLock(KeyOrKeys :: term() | [term()]) -> true | ltimeout.
tryLock(KeyOrKeys) ->
tryLock(KeyOrKeys, ?LockTimeOut).
tryLock(KeyOrKeys, TimeOut) ->
doTryLock(KeyOrKeys, TimeOut).
doTryLock(KeyOrKeys, TimeOut) ->
case eNifLock:tryLock(KeyOrKeys) of
true ->
true;
_ ->
loopLock(KeyOrKeys, TimeOut)
end.
loopLock(KeyOrKeys, TimeOut) ->
receive
after ?ReTryTime ->
LTimeOut = ?CASE(TimeOut == infinity, TimeOut, TimeOut - ?ReTryTime),
case LTimeOut >= 0 of
true ->
case eNifLock:tryLock(KeyOrKeys) of
true ->
true;
_ ->
loopLock(KeyOrKeys, LTimeOut)
end;
_ ->
ltimeout
end
end.
-spec releaseLock(KeyOrKeys :: term() | [term()]) -> ok.
releaseLock(KeyOrKeys) ->
eNifLock:releaseLocks(KeyOrKeys).
-spec getLockPid(KeyOrKeys :: term() | [term()]) -> ok.
getLockPid(KeyOrKeys) ->
case is_list(KeyOrKeys) of
true ->
[{OneKey, eNifLock:getLockPid(OneKey)} || OneKey <- KeyOrKeys];
_ ->
{KeyOrKeys, eNifLock:getLockPid(KeyOrKeys)}
end.
-spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}) -> term() | {error, ltimeout} | {error, {lock_apply_error, term()}}.
lockApply(KeyOrKeys, MFAOrFun) ->
lockApply(KeyOrKeys, MFAOrFun, ?LockTimeOut).
-spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}, TimeOut :: integer() | infinity) -> term().
lockApply(KeyOrKeys, MFAOrFun, TimeOut) ->
case doTryLock(KeyOrKeys, TimeOut) of
true ->
try doApply(MFAOrFun)
catch C:R:S ->
{error, {lock_apply_error, {C, R, S}}}
after
eNifLock:releaseLock(KeyOrKeys),
ok
end;
ltimeout ->
{error, ltimeout}
end.
doApply({M, F, Args}) ->
apply(M, F, Args);
doApply({Fun, Args}) ->
apply(Fun, Args).

+ 1
- 2
src/eGLock.app.src Visa fil

@ -1,8 +1,7 @@
{application, eGLock,
[{description, "An OTP application"},
[{description, "An OTP library"},
{vsn, "0.1.0"},
{registered, []},
{mod, {eGLock_app, []}},
{applications, [kernel, stdlib]},
{env, []},
{modules, []},

+ 30
- 163
src/eGLock.erl Visa fil

@ -1,217 +1,84 @@
-module(eGLock).
-include("eGLock.hrl").
-define(CASE(Cond, Then, That), case Cond of true -> Then; _ -> That end).
%% :Ms
-define(LockTimeOut, 5000).
%% :Ms
-define(ReTryTime, 3).
-export([
tryLock/1
, tryLock/2
, releaseLock/1
, getLockPid/1
, lockApply/2
, lockApply/3
]).
-spec tryLock(KeyOrKeys :: term() | [term()]) -> ok | timeout.
-spec tryLock(KeyOrKeys :: term() | [term()]) -> true | ltimeout.
tryLock(KeyOrKeys) ->
tryLock(KeyOrKeys, ?LockTimeOut).
tryLock(KeyOrKeys, TimeOut) ->
ALockRef = persistent_term:get(?eGLockRef),
PidInt = eGPidInt:pidToInt(self()),
case is_list(KeyOrKeys) of
true ->
KeyIxs = getKexIxs(KeyOrKeys, []),
tryLocks(KeyIxs, ALockRef, PidInt, TimeOut);
_ ->
tryLock(erlang:phash2(KeyOrKeys, ?eGLockSize) + 1, ALockRef, PidInt, TimeOut)
end.
doTryLock(KeyOrKeys, TimeOut).
tryLock(KeyIx, ALockRef, PidInt, TimeOut) ->
case tryLockOne(KeyIx, ALockRef, PidInt) of
ok ->
ok;
doTryLock(KeyOrKeys, TimeOut) ->
case eNifLock:tryLock(KeyOrKeys) of
true ->
true;
_ ->
loopLock(KeyIx, ALockRef, PidInt, TimeOut)
loopLock(KeyOrKeys, TimeOut)
end.
loopLock(KeyIx, ALockRef, PidInt, TimeOut) ->
loopLock(KeyOrKeys, TimeOut) ->
receive
after ?ReTryTime ->
LTimeOut = ?CASE(TimeOut == infinity, TimeOut, TimeOut - ?ReTryTime),
case LTimeOut >= 0 of
true ->
case tryLockOne(KeyIx, ALockRef, PidInt) of
ok ->
ok;
case eNifLock:tryLock(KeyOrKeys) of
true ->
true;
_ ->
loopLock(KeyIx, ALockRef, PidInt, LTimeOut)
loopLock(KeyOrKeys, LTimeOut)
end;
_ ->
timeout
ltimeout
end
end.
tryLocks(KeyIxs, ALockRef, PidInt, TimeOut) ->
case tryLockAll(KeyIxs, ALockRef, PidInt, []) of
ok ->
ok;
_ ->
loopLocks(KeyIxs, ALockRef, PidInt, TimeOut)
end.
loopLocks(KeyIxs, ALockRef, PidInt, TimeOut) ->
receive
after ?ReTryTime ->
LTimeOut = ?CASE(TimeOut == infinity, TimeOut, TimeOut - ?ReTryTime),
case LTimeOut >= 0 of
true ->
case tryLockAll(KeyIxs, ALockRef, PidInt, []) of
ok ->
ok;
_ ->
loopLocks(KeyIxs, ALockRef, PidInt, LTimeOut)
end;
_ ->
timeout
end
end.
-spec releaseLock(KeyOrKeys :: term() | [term()]) -> ok.
releaseLock(KeyOrKeys) ->
ALockRef = persistent_term:get(?eGLockRef),
PidInt = eGPidInt:pidToInt(self()),
eNifLock:releaseLock(KeyOrKeys).
-spec getLockPid(KeyOrKeys :: term() | [term()]) -> ok.
getLockPid(KeyOrKeys) ->
case is_list(KeyOrKeys) of
true ->
KeyIxs = getKexIxs(KeyOrKeys, []),
[atomics:compare_exchange(ALockRef, OneKeyIx, PidInt, 0) || OneKeyIx <- KeyIxs],
ok;
[{OneKey, eNifLock:getLockPid(OneKey)} || OneKey <- KeyOrKeys];
_ ->
atomics:compare_exchange(ALockRef, erlang:phash2(KeyOrKeys, ?eGLockSize) + 1, PidInt, 0),
ok
{KeyOrKeys, eNifLock:getLockPid(KeyOrKeys)}
end.
-spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}) -> term().
-spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}) -> term() | {error, ltimeout} | {error, {lock_apply_error, term()}}.
lockApply(KeyOrKeys, MFAOrFun) ->
lockApply(KeyOrKeys, MFAOrFun, ?LockTimeOut).
-spec lockApply(KeyOrKeys :: term() | [term()], MFAOrFun :: {M :: atom(), F :: atom(), Args :: list()} | {Fun :: function(), Args :: list()}, TimeOut :: integer() | infinity) -> term().
lockApply(KeyOrKeys, MFAOrFun, TimeOut) ->
ALockRef = persistent_term:get(?eGLockRef),
PidInt = eGPidInt:pidToInt(self()),
case is_list(KeyOrKeys) of
case doTryLock(KeyOrKeys, TimeOut) of
true ->
KeyIxs = getKexIxs(KeyOrKeys, []),
lockApplys(KeyIxs, KeyOrKeys, ALockRef, PidInt, MFAOrFun, TimeOut);
_ ->
lockApply(erlang:phash2(KeyOrKeys, ?eGLockSize) + 1, KeyOrKeys, ALockRef, PidInt, MFAOrFun, TimeOut)
end.
lockApply(KeyIx, Key, ALockRef, PidInt, MFAOrFun, TimeOut) ->
case tryLockOne(KeyIx, ALockRef, PidInt) of
ok ->
try doApply(MFAOrFun)
catch C:R:S ->
{error, {lock_apply_error, {C, R, S}}}
after
atomics:exchange(ALockRef, KeyIx, 0),
ok
end;
_ ->
loopApply(KeyIx, Key, ALockRef, PidInt, MFAOrFun, TimeOut)
end.
loopApply(KeyIx, Key, ALockRef, PidInt, MFAOrFun, TimeOut) ->
receive
after ?ReTryTime ->
LTimeOut = ?CASE(TimeOut == infinity, TimeOut, TimeOut - ?ReTryTime),
case LTimeOut >= 0 of
true ->
case tryLockOne(KeyIx, ALockRef, PidInt) of
ok ->
try doApply(MFAOrFun)
catch C:R:S ->
{error, {lock_apply_error, {C, R, S}}}
after
atomics:exchange(ALockRef, KeyIx, 0),
ok
end;
_ ->
loopApply(KeyIx, Key, ALockRef, PidInt, MFAOrFun, LTimeOut)
end;
_ ->
{error, {lock_timeout, Key}}
end
end.
lockApplys(KeyIxs, Keys, ALockRef, PidInt, MFAOrFun, TimeOut) ->
case tryLockAll(KeyIxs, ALockRef, PidInt, []) of
ok ->
try doApply(MFAOrFun)
catch C:R:S ->
{error, {lock_apply_error, {C, R, S}}}
after
[atomics:exchange(ALockRef, KeyIx, 0) || KeyIx <- KeyIxs],
eNifLock:releaseLock(KeyOrKeys),
ok
end;
_ ->
loopApplys(KeyIxs, Keys, ALockRef, PidInt, MFAOrFun, TimeOut)
end.
loopApplys(KeyIxs, Keys, ALockRef, PidInt, MFAOrFun, TimeOut) ->
receive
after ?ReTryTime ->
LTimeOut = ?CASE(TimeOut == infinity, TimeOut, TimeOut - ?ReTryTime),
case LTimeOut >= 0 of
true ->
case tryLockAll(KeyIxs, ALockRef, PidInt, []) of
ok ->
try doApply(MFAOrFun)
catch C:R:S ->
{error, {lock_apply_error, {C, R, S}}}
after
[atomics:exchange(ALockRef, KeyIx, 0) || KeyIx <- KeyIxs],
ok
end;
_ ->
loopApplys(KeyIxs, Keys, ALockRef, PidInt, MFAOrFun, LTimeOut)
end;
_ ->
{error, {lock_timeout, Keys}}
end
end.
getKexIxs([], IxAcc) -> IxAcc;
getKexIxs([Key | Keys], IxAcc) ->
KeyIx = erlang:phash2(Key, ?eGLockSize) + 1,
getKexIxs(Keys, ?CASE(lists:member(KeyIx, IxAcc), IxAcc, [KeyIx | IxAcc])).
tryLockOne(KeyIx, ALockRef, PidInt) ->
case atomics:compare_exchange(ALockRef, KeyIx, 0, PidInt) of
ok ->
ok;
OldPidInt ->
case is_process_alive(eGPidInt:intToPid(OldPidInt)) of
true ->
false;
_ ->
case atomics:compare_exchange(ALockRef, KeyIx, OldPidInt, PidInt) of
ok ->
ok;
_ ->
false
end
end
end.
tryLockAll([], _ALockRef, _PidInt, _LockAcc) ->
ok;
tryLockAll([KeyIx | KeyIxs], ALockRef, PidInt, LockAcc) ->
case tryLockOne(KeyIx, ALockRef, PidInt) of
ok ->
tryLockAll(KeyIxs, ALockRef, PidInt, [KeyIx | LockAcc]);
_ ->
[atomics:compare_exchange(ALockRef, OneLock, PidInt, 0) || OneLock <- LockAcc],
false
ltimeout ->
{error, ltimeout}
end.
doApply({M, F, Args}) ->

+ 0
- 41
src/eGLockMgr.erl Visa fil

@ -1,41 +0,0 @@
-module(eGLockMgr).
-behaviour(gen_server).
-include("eGLock.hrl").
-export([start_link/0]).
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2,
code_change/3]).
-define(SERVER, ?MODULE).
-record(state, {}).
%%%===================================================================
%%% Spawning and gen_server implementation
%%%===================================================================
start_link() ->
gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
init([]) ->
process_flag(trap_exit, true),
ATLockRef = atomics:new(?eGLockSize, [{signed, false}]),
persistent_term:put(?eGLockRef, ATLockRef),
{ok, #state{}}.
handle_call(_Request, _From, State) ->
{reply, ok, State}.
handle_cast(_Request, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.

+ 0
- 11
src/eGLock_app.erl Visa fil

@ -1,11 +0,0 @@
-module(eGLock_app).
-behaviour(application).
-export([start/2, stop/1]).
start(_StartType, _StartArgs) ->
eGLock_sup:start_link().
stop(_State) ->
ok.

+ 0
- 26
src/eGLock_sup.erl Visa fil

@ -1,26 +0,0 @@
-module(eGLock_sup).
-behaviour(supervisor).
-include("eGLock.hrl").
-export([start_link/0]).
-export([init/1]).
-define(SERVER, ?MODULE).
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
init([]) ->
SupFlags = #{strategy => one_for_all, intensity => 100, period => 3600},
ChildSpecs = [
#{
id => eGLockMgr,
start => {eGLockMgr, start_link, []},
restart => permanent,
shutdown => 3000,
type => worker,
modules => [eGLockMgr]
}
],
{ok, {SupFlags, ChildSpecs}}.

+ 0
- 26
src/eGPidInt.erl Visa fil

@ -1,26 +0,0 @@
-module(eGPidInt).
-export([pidToInt/1, intToPid/1]).
-on_load(init/0).
init() ->
SoName =
case code:priv_dir(?MODULE) of
{error, _} ->
case code:which(?MODULE) of
Filename when is_list(Filename) ->
filename:join([filename:dirname(Filename), "../priv", "eGPidInt"]);
_ ->
filename:join("../priv", "eGPidInt")
end;
Dir ->
filename:join(Dir, "eGPidInt")
end,
erlang:load_nif(SoName, 0).
pidToInt(_Term) ->
erlang:nif_error({not_loaded, [{module, ?MODULE}, {line, ?LINE}]}).
intToPid(_Term) ->
erlang:nif_error({not_loaded, [{module, ?MODULE}, {line, ?LINE}]}).

Laddar…
Avbryt
Spara