Created
May 17, 2022 17:48
-
-
Save poseidon4o/e0060063731ca4ecd3d7be473a8a49ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <functional> | |
template <typename Key, typename Value> | |
struct TimedMap { | |
using clock = std::chrono::steady_clock; | |
using time_point = clock::time_point; | |
using callback = std::function<void (const Key &key, const Value &value)>; | |
TimedMap(int concurrencyLimit); | |
void insert(const Key &k, const Value &v, const time_point &expire); | |
void remove(const Key &k); | |
bool find(const Key &k, Value &value); | |
void setExpireCallback(callback &&cb); | |
void removeExpireCallback(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment