Skip to content

Instantly share code, notes, and snippets.

@poseidon4o
Created May 17, 2022 17:48
Show Gist options
  • Save poseidon4o/e0060063731ca4ecd3d7be473a8a49ed to your computer and use it in GitHub Desktop.
Save poseidon4o/e0060063731ca4ecd3d7be473a8a49ed to your computer and use it in GitHub Desktop.
#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