Skip to content

Instantly share code, notes, and snippets.

@SF-Zhou
SF-Zhou / lru.cc
Created December 6, 2019 09:04
C++11 LRU Cache
#include <list>
#include <unordered_map>
class LRUCache {
public:
LRUCache(int capacity) : capacity_(capacity) {}
int get(int key) {
auto it = used_.find(key);
if (it == used_.end()) {
@SF-Zhou
SF-Zhou / hazard_pointer.cc
Last active March 24, 2023 03:37
Lock Free Double Buffer
#include <atomic>
#include <cassert>
#include <iostream>
#include <memory>
#include <mutex>
#include <thread>
#include <vector>
template <class T>
struct HazardPointer {