<commit_before>#ifndef UDPSocket_hpp
#define UDPSocket_hpp

#include <functional>
#include <string>
#include "uv.h"

namespace uvpp {
	namespace internal {
		void onRead(uv_udp_t *udp_socket, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags);
	}
	class UDPSocket {
		friend void internal::onRead(uv_udp_t *udp_socket, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags);

	public:
		using OnDataCallback = std::function<void(std::string data, std::string from_host, int from_port)>;
		using OnErrorCallback = std::function<void(int,std::string)>;

		UDPSocket();
		UDPSocket(const UDPSocket&) = delete;
		UDPSocket(UDPSocket&&);
		UDPSocket(uv_loop_t* loop, int bind_listen_port,
			const OnDataCallback& on_data = nullptr, const OnErrorCallback& on_error = nullptr);
		~UDPSocket();
		UDPSocket& operator=(const UDPSocket&) = delete;
    	UDPSocket& operator=(UDPSocket&& other);
	
		void send(const std::string& send_host, int send_port, const std::string& data);

		void bind(uv_loop_t* loop, int bind_listen_port,
						const OnDataCallback& on_data = nullptr, const OnErrorCallback& on_error = nullptr);
		void unbind();

		bool isListening() const;
		int listening_on_port() const;

		void setOnDataCallback(const OnDataCallback& on_data);
		void setOnErrorCallback(const OnErrorCallback& on_error);

	private:
    void swap(UDPSocket& other);
		void uv_bind_and_listen();

	private:<commit_msg>Change callback params for better performance<commit_after>#ifndef UDPSocket_hpp
#define UDPSocket_hpp

#include <functional>
#include <string>
#include "uv.h"

namespace uvpp {
	namespace internal {
		void onRead(uv_udp_t *udp_socket, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags);
	}
	class UDPSocket {
		friend void internal::onRead(uv_udp_t *udp_socket, ssize_t nread, const uv_buf_t *buf, const struct sockaddr *addr, unsigned flags);

	public:
		using OnDataCallback = std::function<void(const std::string& data, const std::string& from_host, int from_port)>;
		using OnErrorCallback = std::function<void(int, const std::string&)>;

		UDPSocket();
		UDPSocket(const UDPSocket&) = delete;
		UDPSocket(UDPSocket&&);
		UDPSocket(uv_loop_t* loop, int bind_listen_port,
			const OnDataCallback& on_data = nullptr, const OnErrorCallback& on_error = nullptr);
		~UDPSocket();
		UDPSocket& operator=(const UDPSocket&) = delete;
    	UDPSocket& operator=(UDPSocket&& other);
	
		void send(const std::string& send_host, int send_port, const std::string& data);

		void bind(uv_loop_t* loop, int bind_listen_port,
						const OnDataCallback& on_data = nullptr, const OnErrorCallback& on_error = nullptr);
		void unbind();

		bool isListening() const;
		int listening_on_port() const;

		void setOnDataCallback(const OnDataCallback& on_data);
		void setOnErrorCallback(const OnErrorCallback& on_error);

	private:
    void swap(UDPSocket& other);
		void uv_bind_and_listen();

	private:
{'fraction_non_alphanumeric': 0.10651881720430108, 'fraction_numerical': 0.0, 'mean_word_length': 5.923255813953489, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '89949', 'n_tokens_mistral': 1074, 'n_tokens_neox': 997, 'n_words': 262}