2023-06-05 00:16:05 +01:00
|
|
|
/* SPDX-License-Identifier: MPL-2.0 */
|
2015-02-02 01:17:37 +02:00
|
|
|
|
|
|
|
#ifndef __ZMQ_SERVER_HPP_INCLUDED__
|
|
|
|
#define __ZMQ_SERVER_HPP_INCLUDED__
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include "socket_base.hpp"
|
|
|
|
#include "session_base.hpp"
|
|
|
|
#include "stdint.hpp"
|
|
|
|
#include "blob.hpp"
|
|
|
|
#include "fq.hpp"
|
|
|
|
|
|
|
|
namespace zmq
|
|
|
|
{
|
|
|
|
class ctx_t;
|
2018-05-18 17:47:47 +02:00
|
|
|
class msg_t;
|
2015-02-02 01:17:37 +02:00
|
|
|
class pipe_t;
|
|
|
|
|
|
|
|
// TODO: This class uses O(n) scheduling. Rewrite it to use O(1) algorithm.
|
2020-02-09 22:04:56 +02:00
|
|
|
class server_t : public socket_base_t
|
2018-02-01 11:46:09 +01:00
|
|
|
{
|
|
|
|
public:
|
2018-05-24 17:58:30 +02:00
|
|
|
server_t (zmq::ctx_t *parent_, uint32_t tid_, int sid_);
|
2020-02-04 11:57:58 +01:00
|
|
|
~server_t ();
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2015-02-02 01:17:37 +02:00
|
|
|
// Overrides of functions from socket_base_t.
|
2018-07-24 13:48:43 -05:00
|
|
|
void xattach_pipe (zmq::pipe_t *pipe_,
|
|
|
|
bool subscribe_to_all_,
|
2020-02-04 11:57:58 +01:00
|
|
|
bool locally_initiated_);
|
|
|
|
int xsend (zmq::msg_t *msg_);
|
|
|
|
int xrecv (zmq::msg_t *msg_);
|
|
|
|
bool xhas_in ();
|
|
|
|
bool xhas_out ();
|
|
|
|
void xread_activated (zmq::pipe_t *pipe_);
|
|
|
|
void xwrite_activated (zmq::pipe_t *pipe_);
|
|
|
|
void xpipe_terminated (zmq::pipe_t *pipe_);
|
2018-02-01 11:46:09 +01:00
|
|
|
|
|
|
|
private:
|
2015-02-02 01:17:37 +02:00
|
|
|
// Fair queueing object for inbound pipes.
|
2018-05-27 11:10:39 +02:00
|
|
|
fq_t _fq;
|
2018-02-01 11:46:09 +01:00
|
|
|
|
2015-02-02 01:17:37 +02:00
|
|
|
struct outpipe_t
|
|
|
|
{
|
2016-04-25 12:18:46 +01:00
|
|
|
zmq::pipe_t *pipe;
|
2015-02-02 01:17:37 +02:00
|
|
|
bool active;
|
|
|
|
};
|
2016-04-25 12:18:46 +01:00
|
|
|
|
2015-02-02 01:17:37 +02:00
|
|
|
// Outbound pipes indexed by the peer IDs.
|
2018-05-27 11:10:39 +02:00
|
|
|
typedef std::map<uint32_t, outpipe_t> out_pipes_t;
|
|
|
|
out_pipes_t _out_pipes;
|
2016-04-25 12:18:46 +01:00
|
|
|
|
2015-02-02 01:17:37 +02:00
|
|
|
// Routing IDs are generated. It's a simple increment and wrap-over
|
|
|
|
// algorithm. This value is the next ID to use (if not used already).
|
2018-05-27 11:10:39 +02:00
|
|
|
uint32_t _next_routing_id;
|
2015-02-02 01:17:37 +02:00
|
|
|
|
2019-12-08 19:22:04 +01:00
|
|
|
ZMQ_NON_COPYABLE_NOR_MOVABLE (server_t)
|
2018-02-01 11:46:09 +01:00
|
|
|
};
|
2015-02-02 01:17:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|