-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
43 lines (36 loc) · 1.01 KB
/
test.cpp
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
39
40
41
42
43
//
// Created by josqu on 28/06/2021.
//
#include <unistd.h>
#include <iostream>
#include <thread>
#include <vector>
#include <boost/algorithm/string.hpp>
#include <chrono>
#include <cassandra.h>
#include "bgpstream.h"
#include "test.h"
using namespace sw::redis;
using namespace std;
sw::redis::QueuedRedis<sw::redis::PipelineImpl> *pipe_redis;
void MyPersonnelThread(mutex *m) {
mutex *mtx = m;
cout << "MyThread - mtx: " << mtx->try_lock() << endl;
mtx->lock();
cout << "MyThread - locked" << endl;
cout << "MyThread - mtx: " << mtx->try_lock() << endl;
mtx->unlock();
cout << "MyThread - unlocked" << endl;
}
void test::test() {
cout << "vvvvvvvvvvvvvvvvvvvvvvvv Tests vvvvvvvvvvvvvvvvvvvvvvvv" << endl;
mutex mtx;
mtx.lock();
cout << "MainThread - locked" << endl;
thread t(MyPersonnelThread, &mtx);
sleep(5);
mtx.unlock();
cout << "MainThread - unlocked" << endl;
t.join();
cout << "^^^^^^^^^^^^^^^^^^^^^^^^ Tests ^^^^^^^^^^^^^^^^^^^^^^^^" << endl;
}