Comments (4)
Actually, you can update a property value with gproc:set_value(Key, Value).
It could arguably be optimized using ets:update_element/2, but looking at gproc_lib:do_set_value/3, I'm more of a mind to slow it down a bit to make it safer instead.
from gproc.
Thanks for pointing on it! Going to use it in my app. what are consequences of usage of ets:update_element/3? Could we have single function which does "set or update" value for given key? If it doesnt fit into gproc nicely then please close this ticket with no prob.
from gproc.
The things gproc needs to check are:
- The property being updated belongs to the current process
- It's a pre-existing property (which also means gproc is monitoring the
process)
Looking again, gproc_lib:do_set_value/3 could use update_element()
instead of insert(), since the Pid is part of the key. For unique names, it
has to ask the gproc server to do it, since the race condition cannot be
resolved in the client.
Implementing a set_or_update() could possibly have some performance
implications for counters or properties, but personally, I'm not that
excited about the semantics. I personally prefer being explicit about
creating vs updating objects.
2011/12/4 redbaron <
[email protected]
Thanks for pointing on it! Going to use it in my app. what are
consequences of usage of ets:update_element/3? Could we have single
function which does "set or update" value for given key? If it doesnt fit
into gproc nicely then please close this ticket with no prob.
Reply to this email directly or view it on GitHub:
#13 (comment)
from gproc.
Fair enough. Thanks for response.
from gproc.
Related Issues (20)
- Some gproc_dists_tests are very unstable (namely, t_sync_cand_dies, t_fail_node, t_master_dies) HOT 6
- Compiling with OTP 20 yields warnings about crypto:rand_uniform/2 HOT 4
- goodbye() doesn't work in global mode HOT 1
- Can't reset a shared counter
- Unable to start processes in global mode (Elixir)
- Generic server gproc terminating on reg HOT 2
- Warning On OTP 21.2 HOT 1
- aggregated counter can leak HOT 1
- Removing a worker from a pool does not make room for a new worker HOT 1
- gproc_pool round_robin is broken a bit HOT 2
- Monitor stops working if one of the processes monitoring the same name terminates
- Has gen_leader been deprecated ? HOT 1
- Replace key owner HOT 4
- local_only exception error when trying to register Pid golobally HOT 8
- OTP Release 23 depreciated functions HOT 1
- Use a stable app version number HOT 2
- The value of `auto_size` is not judged when the worker is removed HOT 1
- Relase for OTP 24 HOT 2
- If gproc:await finishes with timeout then generic leader gproc_dist terminating with error.
- Tag 1.0.0 is missing
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gproc.