Skip to content

Commit e14be6a

Browse files
committed
Windows Compatibility
1 parent 0e3a034 commit e14be6a

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.16)
33
set(This Example)
44

55
set(Sources
6-
Example.cpp
6+
example.cpp
77
)
88

99
add_executable(${This} ${Sources})

examples/Example.cpp renamed to examples/example.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1+
#include <chrono>
12
#include <iostream>
23
#include <string>
4+
#include <thread>
35
#include <gh-lru/expiring_lru_cache.hpp>
46

5-
#ifdef _WIN32
6-
#include <Windows.h>
7-
#else
8-
#include <unistd.h>
9-
#endif
10-
117
int main()
128
{
139
using Cache = ExpiringLruCache<int, std::string>;
@@ -32,19 +28,14 @@ int main()
3228
std::cout << std::get<0>(cache.find(1)->second) << std::endl; // prints "a"
3329
std::cout << std::get<0>(cache.find(2)->second) << std::endl; // prints "b"
3430

35-
sleep(2);
31+
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
3632
// Refresh the timestamp.
3733
cache.at(1);
3834

39-
sleep(2);
35+
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
4036
std::cout << cache.at(1) << std::endl; // prints "a"
4137
// prints 1 (true), as the element was evicted due to being outdated
4238
std::cout << (cache.find(2) == cache.end()) << std::endl;
4339

44-
std::unordered_map<int, int> map;
45-
map.emplace(1, 10);
46-
map.emplace(1, 11);
47-
std::cout << map.at(1) << std::endl;
48-
4940
return 0;
5041
}

0 commit comments

Comments
 (0)