Extract io/network into mg-io library
Reviewers: buda, dgleich, mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D1411
This commit is contained in:
@@ -3,9 +3,11 @@
|
||||
#include <random>
|
||||
#include <thread>
|
||||
|
||||
#include "threading/sync/futex.hpp"
|
||||
#include <glog/logging.h>
|
||||
|
||||
Futex futex;
|
||||
#include "utils/thread/sync.hpp"
|
||||
|
||||
utils::Futex futex;
|
||||
int x = 0;
|
||||
|
||||
/**
|
||||
@@ -19,7 +21,7 @@ void test_lock(int) {
|
||||
// TODO: create long running test
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
{
|
||||
std::unique_lock<Futex> guard(futex);
|
||||
std::unique_lock<utils::Futex> guard(futex);
|
||||
x++;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(dis(gen)));
|
||||
CHECK(x == 1) << "Other thread shouldn't be able to "
|
||||
|
||||
@@ -6,16 +6,16 @@
|
||||
|
||||
#include "glog/logging.h"
|
||||
|
||||
#include "threading/sync/spinlock.hpp"
|
||||
#include "utils/thread/sync.hpp"
|
||||
|
||||
int x = 0;
|
||||
SpinLock lock;
|
||||
utils::SpinLock lock;
|
||||
|
||||
void test_lock() {
|
||||
using namespace std::literals;
|
||||
|
||||
{
|
||||
std::unique_lock<SpinLock> guard(lock);
|
||||
std::unique_lock<utils::SpinLock> guard(lock);
|
||||
x++;
|
||||
|
||||
std::this_thread::sleep_for(25ms);
|
||||
|
||||
Reference in New Issue
Block a user