/* * Sender.cpp * */ #include "Sender.h" #include "ssl_sockets.h" template void* Sender::run_thread(void* sender) { ((Sender*)sender)->run(); #if OPENSSL_VERSION_NUMBER >= 0x10100000L OPENSSL_thread_stop(); #endif return 0; } template Sender::Sender(T socket) : socket(socket), thread(0) { start(); } template Sender::~Sender() { stop(); } template void Sender::start() { pthread_create(&thread, 0, run_thread, this); } template void Sender::stop() { in.stop(); pthread_join(thread, 0); } template void Sender::run() { const octetStream* os = 0; while (in.pop(os)) { #ifdef VERBOSE_SSL timer.start(); RunningTimer mytimer; #endif os->Send(socket); #ifdef VERBOSE_SSL cout << "sending " << os->get_length() * 1e-6 << " MB on " << socket << " took " << mytimer.elapsed() << ", total " << timer.elapsed() << endl; timer.stop(); #endif out.push(os); } } template void Sender::request(const octetStream& os) { in.push(&os); } template void Sender::wait(const octetStream& os) { const octetStream* queued = 0; out.pop(queued); if (queued != &os) throw not_implemented(); } template class Sender; template class Sender;