|
|
|
|
|
by kccqzy
372 days ago
|
|
I took a brief look at your link. How does this even qualify to be RCU? The read-copy-update paradigm requires that the update step be able to know whether the value to be updated is derived from the recent copy. The set function here doesn't even allow you to atomically compare your read version against the current version. Imagine you are implementing a simple array with RCU; you read the array, make a copy, append to the array, and then you need to atomically compare the array pointer pre-append and set the array just so that you don't lose writes by other threads. |
|
The set function will not invalidate any values seen by get that might still be referenced, but the new value will be seen by all subsequent gets.
Old values will be destructed when no longer referenced.
To read-copy-update you'll need to take a lock (that readers don't), get the current value (it will be the current one given you're locking out other writers), copy it, modify the copy, then set the new value.
You don't have to read-copy-update if the new values don't depend on the preceding values. So my API does not force read-copy-update, but you can do RCU with it.