Accesses a double value used for transmitting shared data between elements.
More...
#include <Block.hpp>
Public Member Functions | |
| Shared_value (Vertex &) | |
Sets the Lock | |
| double | get (int recursion_depth=100) const |
| Fetches the shared value. | |
| void | set (double) |
| Writes to the shared value. | |
| void | set (double value, bool minmax, int recursion_depth=100) |
Constrains the value of get() to be at most (least) value if minamx is false (true). | |
Accesses a double value used for transmitting shared data between elements.
There are several cases where elements have some data which needs to match their vertex neighbors. For this purpose, every Vertex has a single (private) double data member, it's "shared value". When you construct a Shared_value object from a Vertex, its get() and set() members will access the shared value of the vertex. The Shared_value also acquires a Lock belonging to the vertex on construction and releases it on destruction, so you get() and set() are thread safe. However, if you need to do an update operation (one that involves both get() and set(), you should call both members on the same Shared_value object so that the lock will prevent any other thread from changing the shared value in between the get() and set(). When you construct a Vertex, its shared value is initialized to 0.
| void hexed::next::Vertex::Shared_value::set | ( | double | value | ) |
Writes to the shared value.
Will not directly affect the get() if the vertex is glued.