uwiger / gproc

Extended process registry for Erlang
Apache License 2.0
1.07k stars 232 forks source link

Shared property #93

Open benbro opened 9 years ago

benbro commented 9 years ago

It might be useful to have a shared property that is created with the first pid and deleted when the last pid using this property is killed. For example, we can store a shared encryption key in a chat room that all the room participants can use. The key will be created when the first participant joins the room and will be deleted when the last participant exists the room.

Syntax might be:

% set a shared property
% the property will monitor the pid
gproc:set_shared_property(Key, Value).

% get a shared property
% the property will monitor the pid
gproc:get_shared_property(Key, Value).

% get a shared property if exists, or set it if not
% the property will monitor the pid
{ok, Value} = gproc:get_or_set_shared_property(Key, NewValue).

Thanks