preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SocketSendQueue.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <boost/asio.hpp>
4#include <deque>
5#include <functional>
6#include <memory>
7#include <mutex>
8#include <string>
9#include "logging/Logger.hpp"
10
11namespace precice::com {
12
16public:
17 using Socket = boost::asio::ip::tcp::socket;
18
19 SocketSendQueue() = default;
21
24
26 void dispatch(std::shared_ptr<Socket> sock, boost::asio::const_buffer data, std::function<void()> callback);
27
29 void sendCompleted();
30
31private:
33 void process();
34
35 struct SendItem {
37 boost::asio::const_buffer data;
39 };
40
46 bool _ready = true;
47};
48
49} // namespace precice::com
bool _ready
Is the queue allowed to start another asynchronous send?
boost::asio::ip::tcp::socket Socket
SocketSendQueue(SocketSendQueue const &)=delete
void sendCompleted()
Notifies the queue that the last asynchronous send operation has completed.
std::mutex _queueMutex
The mutex protecting access to the queue.
std::deque< SendItem > _itemQueue
The queue, containing items to asynchronously send using boost.asio.
void dispatch(std::shared_ptr< Socket > sock, boost::asio::const_buffer data, std::function< void()> callback)
Put data in the queue, start processing the queue.
~SocketSendQueue()
If items are left in the queue upon destruction, something went really wrong.
SocketSendQueue & operator=(SocketSendQueue const &)=delete
void process()
This method can be called arbitrarily many times, but enough times to ensure the queue makes progress...
contains the data communication abstraction layer.