mirror of
https://github.com/data61/MP-SPDZ.git
synced 2026-01-10 05:57:57 -05:00
55 lines
806 B
C++
55 lines
806 B
C++
// (C) 2016 University of Bristol. See License.txt
|
|
|
|
/*
|
|
* Sender.cpp
|
|
*
|
|
*/
|
|
|
|
#include "Sender.h"
|
|
|
|
void* run_sender_thread(void* sender)
|
|
{
|
|
((Sender*)sender)->run();
|
|
return 0;
|
|
}
|
|
|
|
Sender::Sender(int socket) : socket(socket), thread(0)
|
|
{
|
|
}
|
|
|
|
void Sender::start()
|
|
{
|
|
pthread_create(&thread, 0, run_sender_thread, this);
|
|
}
|
|
|
|
void Sender::stop()
|
|
{
|
|
in.stop();
|
|
pthread_join(thread, 0);
|
|
}
|
|
|
|
void Sender::run()
|
|
{
|
|
const octetStream* os = 0;
|
|
while (in.pop(os))
|
|
{
|
|
// timer.start();
|
|
os->Send(socket);
|
|
// timer.stop();
|
|
out.push(os);
|
|
}
|
|
}
|
|
|
|
void Sender::request(const octetStream& os)
|
|
{
|
|
in.push(&os);
|
|
}
|
|
|
|
void Sender::wait(const octetStream& os)
|
|
{
|
|
const octetStream* queued = 0;
|
|
out.pop(queued);
|
|
if (queued != &os)
|
|
throw not_implemented();
|
|
}
|