?this is fine?

old
Brett 2023-11-03 14:36:43 -04:00
parent 0664ce85eb
commit fc6530cc45
3 changed files with 47 additions and 5 deletions

View File

@ -1,3 +1,3 @@
Start testing: Nov 02 16:40 EDT
Start testing: Nov 03 13:32 EDT
----------------------------------------------------------
End testing: Nov 02 16:40 EDT
End testing: Nov 03 13:32 EDT

View File

@ -1 +1 @@
hello this is big data how may i help you?
hello this is big data how may i help you? hey hey hey u

View File

@ -1,5 +1,5 @@
/*
* Mail file containing the program entry point. I really want to name all this all femboy themed
* Main file containing the program entry point. I really want to name all this all femboy themed
* Copyright (C) 2023 Brett Terpstra
*
* This program is free software: you can redistribute it and/or modify
@ -27,6 +27,9 @@
#include <ios>
#include <cstdint>
#include <memory>
#include <thread>
#include <mutex>
#include <atomic>
constexpr size_t PACKET_SIZE = 512;
@ -126,7 +129,46 @@ void mangle(packet& packet)
}
}
void process_packets(const std::vector<packet> packets)
class pipe
{
private:
std::random_device dev{};
std::mt19937_64 engine{dev()};
std::uniform_real_distribution<double> dist{0.0, 1.0};
packet buffer;
std::atomic<bool> is_written{false};
public:
pipe() = default;
void send(packet packet)
{
while (is_written.load(std::memory_order::memory_order_acquire))
std::this_thread::sleep_for(std::chrono::milliseconds(1));
// 10% chance to drop the packet all together
if (dist(engine) < 0.1)
return;
buffer = std::move(packet);
is_written.store(true, std::memory_order::memory_order_release);
}
void receive(packet& out)
{
while (!is_written.load(std::memory_order::memory_order_acquire))
std::this_thread::sleep_for(std::chrono::milliseconds(1));
out = packet(buffer);
mangle(out);
is_written.store(false, std::memory_order::memory_order_release);
}
};
void process_packets(const std::vector<packet>& packets)
{
}