-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cc
More file actions
38 lines (32 loc) · 1.04 KB
/
test.cc
File metadata and controls
38 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "lock_free_skip_list.h"
#include <thread>
int main() {
LockFreeSkipList<int> l(1, 10000);
std::cout << "inserting" << std::endl;
std::cout << 6 << std::endl;
l.insert(6);
std::cout << "inserting" << std::endl;
std::cout << 226 << std::endl;
l.insert(226);
std::cout << "inserting" << std::endl;
std::cout << 126 << std::endl;
std::cout << "inserting in parallel 126 and 226" << std::endl;
std::thread t1(&LockFreeSkipList<int>::insert, std::ref(l), 126);
std::thread t2(&LockFreeSkipList<int>::insert, std::ref(l), 226);
t2.join();
t1.join();
std::cout << "inserting" << std::endl;
std::cout << 1226 << std::endl;
l.insert(1226);
std::cout << "inserting" << std::endl;
std::cout << 26 << std::endl;
l.insert(26);
std::cout << "remove" << std::endl;
l.remove(26);
std::cout << "inserting in parallel 126 and 226" << std::endl;
std::thread t3(&LockFreeSkipList<int>::insert, std::ref(l), 526);
std::thread t4(&LockFreeSkipList<int>::insert, std::ref(l), 26);
t3.join();
t4.join();
return 0;
}