Skip to content

Commit

Permalink
Vutils
Browse files Browse the repository at this point in the history
  • Loading branch information
vic4key committed Oct 28, 2023
1 parent 69efdf7 commit 157d7db
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/Vutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,8 @@ class Debouncer : public SingletonT<Debouncer>
Timer() : m_handle(0), m_function(nullptr) {}
};

virtual ~Debouncer();

void debounce(ulongptr id, ulong elapse, std::function<void()> fn);
bool exists(ulongptr id);
void remove(ulongptr id);
Expand Down
6 changes: 4 additions & 2 deletions include/template/singleton.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ public:
}
}

// SingletonT(SingletonT&) = delete;
// void operator=(const SingletonT&) = delete;
SingletonT(SingletonT&&) = delete;
SingletonT(SingletonT const&) = delete;
SingletonT& operator=(SingletonT&&) = delete;
SingletonT& operator=(SingletonT const&) = delete;

static T& instance()
{
Expand Down
5 changes: 5 additions & 0 deletions src/details/debouncer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ namespace vu
ulongptr Debouncer::m_using_timer_id;
std::unordered_map<ulongptr, Debouncer::Timer*> Debouncer::m_timers;

Debouncer::~Debouncer()
{
this->cleanup();
}

bool Debouncer::exists(ulongptr id)
{
auto it = m_timers.find(id);
Expand Down

0 comments on commit 157d7db

Please sign in to comment.