Fixed bug with VN scrolling
This commit is contained in:
@ -7,13 +7,18 @@
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
UsageLock::UsageLock() {
|
||||
UsageLock::UsageLock() : UsageLock(&this->internalPool) {
|
||||
}
|
||||
|
||||
UsageLock::UsageLock(usagelockid_t *lockPool) {
|
||||
assertNotNull(lockPool);
|
||||
this->pool = lockPool;
|
||||
this->onEmpty = []() {};
|
||||
this->onFirstLock = []() {};
|
||||
}
|
||||
|
||||
usagelockid_t UsageLock::createLock() {
|
||||
usagelockid_t lock = this->nextLock++;
|
||||
usagelockid_t lock = (*this->pool)++;
|
||||
this->locks.push_back(lock);
|
||||
if(this->locks.size() == 1) this->onFirstLock();
|
||||
return lock;
|
||||
@ -23,5 +28,6 @@ void UsageLock::removeLock(usagelockid_t lock) {
|
||||
auto it = std::find(this->locks.begin(), this->locks.end(), lock);
|
||||
if(it == this->locks.end()) return;
|
||||
this->locks.erase(it);
|
||||
this->onLockRemoved(lock);
|
||||
if(this->locks.size() == 0) this->onEmpty();
|
||||
}
|
@ -10,18 +10,27 @@ namespace Dawn {
|
||||
|
||||
class UsageLock {
|
||||
protected:
|
||||
usagelockid_t nextLock = 0;
|
||||
usagelockid_t internalPool = 0;
|
||||
usagelockid_t *pool = nullptr;
|
||||
std::vector<usagelockid_t> locks;
|
||||
|
||||
public:
|
||||
std::function<void()> onEmpty;
|
||||
std::function<void()> onFirstLock;
|
||||
std::function<void(usagelockid_t)> onLockRemoved;
|
||||
|
||||
/**
|
||||
* Construct a new usage lock object.
|
||||
*/
|
||||
UsageLock();
|
||||
|
||||
/**
|
||||
* Construct a new Usage Lock object
|
||||
*
|
||||
* @param lockPool Pool that will be used to create locks.
|
||||
*/
|
||||
UsageLock(usagelockid_t *lockPool);
|
||||
|
||||
/**
|
||||
* Creates a new lock.
|
||||
*
|
||||
|
Reference in New Issue
Block a user