mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Merge #5883: refactor: use atomic to avoid blocking chainlocks cs on each call to cleanup
75d81fd2c0
refactor: use atomic to avoid blocking chainlocks cs on each call to cleanup (pasta)
Pull request description:
## Issue being fixed or feature implemented
Avoid needing to lock CS on each call to cleanup. Cleanup only gets called once every 5 seconds it seems; but maybe that'll change in the future.
## What was done?
Make `lastCleanupTime` atomic instead of CS guarded
## How Has This Been Tested?
Building
## Breaking Changes
None
## Checklist:
_Go over all the following points, and put an `x` in all the boxes that apply._
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have added or updated relevant unit/integration/functional/e2e tests
- [ ] I have made corresponding changes to the documentation
- [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
Top commit has no ACKs.
Tree-SHA512: 587dbfbecce430c25b4d572b2e158fcda86aced3db976c16166c0cabcf960f46d300739bbf54644def30769347cc88ac14c58d71dd78d848f7d8af562cd12bc6
This commit is contained in:
commit
d6b5590c18
@ -617,12 +617,9 @@ void CChainLocksHandler::Cleanup()
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(cs);
|
||||
if (GetTimeMillis() - lastCleanupTime < CLEANUP_INTERVAL) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// need mempool.cs due to GetTransaction calls
|
||||
LOCK2(cs_main, mempool.cs);
|
||||
|
@ -82,7 +82,7 @@ private:
|
||||
|
||||
std::map<uint256, int64_t> seenChainLocks GUARDED_BY(cs);
|
||||
|
||||
int64_t lastCleanupTime GUARDED_BY(cs) {0};
|
||||
std::atomic<int64_t> lastCleanupTime{0};
|
||||
|
||||
public:
|
||||
explicit CChainLocksHandler(CChainState& chainstate, CConnman& _connman, CMasternodeSync& mn_sync, CQuorumManager& _qman,
|
||||
|
Loading…
Reference in New Issue
Block a user