-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LOCK properly, everywhere, where necessary #94
Comments
Hmm... #100 locks Is the following statement correct?
I'm wondering about the UI and RPC though. Ideally we would have something like: And set a "write lock", when entering the handlers, and "read locks", when reading via RPC or UI. If a read lock is set, then no write lock shall be set, and if the write lock is set, no read lock shall be set. More than one read lock may be set at the time, but no more than one write lock. Or in other words:
The Boost equivalents seem to be: // QReadWriteLock lock;
boost::shared_mutex lock;
void writeData(const T& data)
{
// QWriteLocker locker(&lock);
boost::unique_lock<boost::shared_mutex> locker(lock);
...
}
T readData()
{
// QReadLocker locker(&lock);
boost::shared_lock<boost::shared_mutex> locker(lock);
...
} Currently I see the following problems:
Since Boost 1.52 the following lines were added to the documentation:
It's great to know that it's "fair", but this isn't really tangible for me. I think I'm going to try to implement a PoC, but I really need at least a good idea how to test it. The locking test works as follows:
Without lock, the local copy of To test a read-write scheme, there could be:
That should at least show, whether the reader threads really get incrementing numbers. |
Locks are used to ensure not more than one thread at the time enters a "locked" region, for example to prevent that thread A writes some data, and another thread B (for example UI, RPC) reads at that moment.
Currently there are a few places where
LOCKs
are likely missing.The following parts should be guarded:
The lock we currently use is
cs_tally
, whereby I think it would make sense to use a seperated one for the pending transaction objects, and probably for the caches, especially the UI-only caches, too.The text was updated successfully, but these errors were encountered: