Git Product home page Git Product logo

Comments (4)

uwiger avatar uwiger commented on August 25, 2024

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.

redbaron avatar redbaron commented on August 25, 2024

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.

uwiger avatar uwiger commented on August 25, 2024

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.

redbaron avatar redbaron commented on August 25, 2024

Fair enough. Thanks for response.

from gproc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.