mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
SCRIPT namespace replacements
This commit is contained in:
committed by
Peter Johnson
parent
ae6c043632
commit
9aca8e0fd6
@@ -10,7 +10,7 @@
|
||||
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class Logger;
|
||||
|
||||
@@ -24,32 +24,32 @@ class DsClient : public std::enable_shared_from_this<DsClient> {
|
||||
struct private_init {};
|
||||
|
||||
public:
|
||||
static std::shared_ptr<DsClient> Create(wpi::uv::Loop& loop,
|
||||
wpi::Logger& logger) {
|
||||
static std::shared_ptr<DsClient> Create(wpi::net::uv::Loop& loop,
|
||||
wpi::util::Logger& logger) {
|
||||
return std::make_shared<DsClient>(loop, logger, private_init{});
|
||||
}
|
||||
|
||||
DsClient(wpi::uv::Loop& loop, wpi::Logger& logger, const private_init&);
|
||||
DsClient(wpi::net::uv::Loop& loop, wpi::util::Logger& logger, const private_init&);
|
||||
~DsClient();
|
||||
DsClient(const DsClient&) = delete;
|
||||
DsClient& operator=(const DsClient&) = delete;
|
||||
|
||||
void Close();
|
||||
|
||||
sig::Signal<std::string_view> setIp;
|
||||
sig::Signal<> clearIp;
|
||||
wpi::util::sig::Signal<std::string_view> setIp;
|
||||
wpi::util::sig::Signal<> clearIp;
|
||||
|
||||
private:
|
||||
void Connect();
|
||||
void HandleIncoming(std::string_view in);
|
||||
void ParseJson();
|
||||
|
||||
wpi::Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
|
||||
std::shared_ptr<wpi::uv::Tcp> m_tcp;
|
||||
std::shared_ptr<wpi::uv::Timer> m_timer;
|
||||
std::shared_ptr<wpi::net::uv::Tcp> m_tcp;
|
||||
std::shared_ptr<wpi::net::uv::Timer> m_timer;
|
||||
|
||||
std::string m_json;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "wpi/net/uv/Loop.hpp"
|
||||
#include "wpi/util/SafeThread.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* Executes an event loop on a separate thread.
|
||||
@@ -54,9 +54,9 @@ class EventLoopRunner {
|
||||
|
||||
private:
|
||||
class Thread;
|
||||
SafeThreadOwner<Thread> m_owner;
|
||||
wpi::util::SafeThreadOwner<Thread> m_owner;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_EVENTLOOPRUNNER_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/util/Signal.h"
|
||||
#include "wpi/util/SmallString.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* HTTP protocol parser. Performs incremental parsing with callbacks for each
|
||||
@@ -143,14 +143,14 @@ class HttpParser {
|
||||
/**
|
||||
* Message begin callback.
|
||||
*/
|
||||
sig::Signal<> messageBegin;
|
||||
wpi::util::sig::Signal<> messageBegin;
|
||||
|
||||
/**
|
||||
* URL callback.
|
||||
*
|
||||
* The parameter to the callback is the complete URL string.
|
||||
*/
|
||||
sig::Signal<std::string_view> url;
|
||||
wpi::util::sig::Signal<std::string_view> url;
|
||||
|
||||
/**
|
||||
* Status callback.
|
||||
@@ -158,14 +158,14 @@ class HttpParser {
|
||||
* The parameter to the callback is the complete status string.
|
||||
* GetStatusCode() can be used to get the numeric status code.
|
||||
*/
|
||||
sig::Signal<std::string_view> status;
|
||||
wpi::util::sig::Signal<std::string_view> status;
|
||||
|
||||
/**
|
||||
* Header field callback.
|
||||
*
|
||||
* The parameters to the callback are the field name and field value.
|
||||
*/
|
||||
sig::Signal<std::string_view, std::string_view> header;
|
||||
wpi::util::sig::Signal<std::string_view, std::string_view> header;
|
||||
|
||||
/**
|
||||
* Headers complete callback.
|
||||
@@ -175,7 +175,7 @@ class HttpParser {
|
||||
* connection. If you are the server, respond with the "Connection: close"
|
||||
* header. If you are the client, close the connection.
|
||||
*/
|
||||
sig::Signal<bool> headersComplete;
|
||||
wpi::util::sig::Signal<bool> headersComplete;
|
||||
|
||||
/**
|
||||
* Body data callback.
|
||||
@@ -185,7 +185,7 @@ class HttpParser {
|
||||
* multiple times arbitrarily (e.g. it's possible that it may be called with
|
||||
* just a few characters at a time).
|
||||
*/
|
||||
sig::Signal<std::string_view, bool> body;
|
||||
wpi::util::sig::Signal<std::string_view, bool> body;
|
||||
|
||||
/**
|
||||
* Headers complete callback.
|
||||
@@ -195,19 +195,19 @@ class HttpParser {
|
||||
* connection. If you are the server, respond with the "Connection: close"
|
||||
* header. If you are the client, close the connection.
|
||||
*/
|
||||
sig::Signal<bool> messageComplete;
|
||||
wpi::util::sig::Signal<bool> messageComplete;
|
||||
|
||||
/**
|
||||
* Chunk header callback.
|
||||
*
|
||||
* The parameter to the callback is the chunk size.
|
||||
*/
|
||||
sig::Signal<uint64_t> chunkHeader;
|
||||
wpi::util::sig::Signal<uint64_t> chunkHeader;
|
||||
|
||||
/**
|
||||
* Chunk complete callback.
|
||||
*/
|
||||
sig::Signal<> chunkComplete;
|
||||
wpi::util::sig::Signal<> chunkComplete;
|
||||
|
||||
private:
|
||||
http_parser m_parser;
|
||||
@@ -215,13 +215,13 @@ class HttpParser {
|
||||
|
||||
size_t m_maxLength = 1024;
|
||||
enum { kStart, kUrl, kStatus, kField, kValue } m_state = kStart;
|
||||
SmallString<128> m_urlBuf;
|
||||
SmallString<32> m_fieldBuf;
|
||||
SmallString<128> m_valueBuf;
|
||||
wpi::util::SmallString<128> m_urlBuf;
|
||||
wpi::util::SmallString<32> m_fieldBuf;
|
||||
wpi::util::SmallString<128> m_valueBuf;
|
||||
|
||||
bool m_aborted = false;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_HTTPPARSER_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/net/HttpParser.hpp"
|
||||
#include "wpi/net/uv/Stream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class raw_ostream;
|
||||
|
||||
@@ -49,7 +49,7 @@ class HttpServerConnection {
|
||||
*
|
||||
* @param os response stream
|
||||
*/
|
||||
virtual void BuildCommonHeaders(raw_ostream& os);
|
||||
virtual void BuildCommonHeaders(wpi::util::raw_ostream& os);
|
||||
|
||||
/**
|
||||
* Build HTTP response header, along with other header information like
|
||||
@@ -63,7 +63,7 @@ class HttpServerConnection {
|
||||
* be set to false.
|
||||
* @param extra Extra HTTP headers to send, including final "\r\n"
|
||||
*/
|
||||
virtual void BuildHeader(raw_ostream& os, int code, std::string_view codeText,
|
||||
virtual void BuildHeader(wpi::util::raw_ostream& os, int code, std::string_view codeText,
|
||||
std::string_view contentType, uint64_t contentLength,
|
||||
std::string_view extra = {});
|
||||
|
||||
@@ -138,15 +138,15 @@ class HttpServerConnection {
|
||||
uv::Stream& m_stream;
|
||||
|
||||
/** The header reader connection. */
|
||||
sig::ScopedConnection m_dataConn;
|
||||
wpi::util::sig::ScopedConnection m_dataConn;
|
||||
|
||||
/** The end stream connection. */
|
||||
sig::ScopedConnection m_endConn;
|
||||
wpi::util::sig::ScopedConnection m_endConn;
|
||||
|
||||
/** The message complete connection. */
|
||||
sig::Connection m_messageCompleteConn;
|
||||
wpi::util::sig::Connection m_messageCompleteConn;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_HTTPSERVERCONNECTION_HPP_
|
||||
|
||||
@@ -22,26 +22,26 @@
|
||||
#include "wpi/util/StringMap.hpp"
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
// Unescape a %xx-encoded URI.
|
||||
// @param buf Buffer for output
|
||||
// @param error Set to true if an error occurred
|
||||
// @return Escaped string
|
||||
std::string_view UnescapeURI(std::string_view str, SmallVectorImpl<char>& buf,
|
||||
std::string_view UnescapeURI(std::string_view str, wpi::util::SmallVectorImpl<char>& buf,
|
||||
bool* error);
|
||||
|
||||
// Escape a string with %xx-encoding.
|
||||
// @param buf Buffer for output
|
||||
// @param spacePlus If true, encodes spaces to '+' rather than "%20"
|
||||
// @return Escaped string
|
||||
std::string_view EscapeURI(std::string_view str, SmallVectorImpl<char>& buf,
|
||||
std::string_view EscapeURI(std::string_view str, wpi::util::SmallVectorImpl<char>& buf,
|
||||
bool spacePlus = true);
|
||||
|
||||
// Escape a string for HTML output.
|
||||
// @param buf Buffer for output
|
||||
// @return Escaped string
|
||||
std::string_view EscapeHTML(std::string_view str, SmallVectorImpl<char>& buf);
|
||||
std::string_view EscapeHTML(std::string_view str, wpi::util::SmallVectorImpl<char>& buf);
|
||||
|
||||
// Parse a set of HTTP headers. Saves just the Content-Type and Content-Length
|
||||
// fields.
|
||||
@@ -49,8 +49,8 @@ std::string_view EscapeHTML(std::string_view str, SmallVectorImpl<char>& buf);
|
||||
// @param contentType If not null, Content-Type contents are saved here.
|
||||
// @param contentLength If not null, Content-Length contents are saved here.
|
||||
// @return False if error occurred in input stream
|
||||
bool ParseHttpHeaders(raw_istream& is, SmallVectorImpl<char>* contentType,
|
||||
SmallVectorImpl<char>* contentLength);
|
||||
bool ParseHttpHeaders(wpi::util::raw_istream& is, wpi::util::SmallVectorImpl<char>* contentType,
|
||||
wpi::util::SmallVectorImpl<char>* contentLength);
|
||||
|
||||
// Look for a MIME multi-part boundary. On return, the input stream will
|
||||
// be located at the character following the boundary (usually "\r\n").
|
||||
@@ -59,7 +59,7 @@ bool ParseHttpHeaders(raw_istream& is, SmallVectorImpl<char>* contentType,
|
||||
// @param saveBuf If not null, all scanned characters up to but not including
|
||||
// the boundary are saved to this string
|
||||
// @return False if error occurred on input stream, true if boundary found.
|
||||
bool FindMultipartBoundary(wpi::raw_istream& is, std::string_view boundary,
|
||||
bool FindMultipartBoundary(wpi::util::raw_istream& is, std::string_view boundary,
|
||||
std::string* saveBuf);
|
||||
|
||||
/**
|
||||
@@ -93,10 +93,10 @@ class HttpQueryMap {
|
||||
* name is not present in the query map.
|
||||
*/
|
||||
std::optional<std::string_view> Get(std::string_view name,
|
||||
SmallVectorImpl<char>& buf) const;
|
||||
wpi::util::SmallVectorImpl<char>& buf) const;
|
||||
|
||||
private:
|
||||
StringMap<std::string_view> m_elems;
|
||||
wpi::util::StringMap<std::string_view> m_elems;
|
||||
};
|
||||
|
||||
class HttpPathRef;
|
||||
@@ -224,8 +224,8 @@ class HttpPath {
|
||||
HttpPathRef drop_front(size_t n) const;
|
||||
|
||||
private:
|
||||
SmallString<128> m_pathBuf;
|
||||
SmallVector<size_t, 16> m_pathEnds;
|
||||
wpi::util::SmallString<128> m_pathBuf;
|
||||
wpi::util::SmallVector<size_t, 16> m_pathEnds;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -322,7 +322,7 @@ class HttpRequest {
|
||||
template <typename T>
|
||||
HttpRequest(const HttpLocation& loc, const T& extraParams)
|
||||
: host{loc.host}, port{loc.port} {
|
||||
SmallVector<std::pair<std::string_view, std::string_view>, 4> params;
|
||||
wpi::util::SmallVector<std::pair<std::string_view, std::string_view>, 4> params;
|
||||
for (const auto& p : loc.params) {
|
||||
params.emplace_back(std::pair{GetFirst(p), GetSecond(p)});
|
||||
}
|
||||
@@ -345,10 +345,10 @@ class HttpRequest {
|
||||
SetAuth(loc);
|
||||
}
|
||||
|
||||
SmallString<128> host;
|
||||
wpi::util::SmallString<128> host;
|
||||
int port;
|
||||
std::string auth;
|
||||
SmallString<128> path;
|
||||
wpi::util::SmallString<128> path;
|
||||
|
||||
private:
|
||||
void SetAuth(const HttpLocation& loc);
|
||||
@@ -356,7 +356,7 @@ class HttpRequest {
|
||||
template <typename T>
|
||||
void SetPath(std::string_view path_, const T& params) {
|
||||
// Build location including query string
|
||||
raw_svector_ostream pathOs{path};
|
||||
wpi::util::raw_svector_ostream pathOs{path};
|
||||
pathOs << path_;
|
||||
bool first = true;
|
||||
for (const auto& param : params) {
|
||||
@@ -366,7 +366,7 @@ class HttpRequest {
|
||||
} else {
|
||||
pathOs << '&';
|
||||
}
|
||||
SmallString<64> escapeBuf;
|
||||
wpi::util::SmallString<64> escapeBuf;
|
||||
pathOs << EscapeURI(GetFirst(param), escapeBuf, false);
|
||||
if (!GetSecond(param).empty()) {
|
||||
pathOs << '=' << EscapeURI(GetSecond(param), escapeBuf, false);
|
||||
@@ -390,18 +390,18 @@ class HttpRequest {
|
||||
|
||||
class HttpConnection {
|
||||
public:
|
||||
HttpConnection(std::unique_ptr<wpi::NetworkStream> stream_, int timeout)
|
||||
HttpConnection(std::unique_ptr<wpi::net::NetworkStream> stream_, int timeout)
|
||||
: stream{std::move(stream_)}, is{*stream, timeout}, os{*stream, true} {}
|
||||
|
||||
bool Handshake(const HttpRequest& request, std::string* warnMsg);
|
||||
|
||||
std::unique_ptr<wpi::NetworkStream> stream;
|
||||
wpi::raw_socket_istream is;
|
||||
wpi::raw_socket_ostream os;
|
||||
std::unique_ptr<wpi::net::NetworkStream> stream;
|
||||
wpi::net::raw_socket_istream is;
|
||||
wpi::net::raw_socket_ostream os;
|
||||
|
||||
// Valid after Handshake() is successful
|
||||
SmallString<64> contentType;
|
||||
SmallString<64> contentLength;
|
||||
wpi::util::SmallString<64> contentType;
|
||||
wpi::util::SmallString<64> contentLength;
|
||||
|
||||
explicit operator bool() const { return stream && !is.has_error(); }
|
||||
};
|
||||
@@ -436,7 +436,7 @@ class HttpMultipartScanner {
|
||||
}
|
||||
|
||||
private:
|
||||
SmallString<64> m_boundaryWith, m_boundaryWithout;
|
||||
wpi::util::SmallString<64> m_boundaryWith, m_boundaryWithout;
|
||||
|
||||
// Internal state
|
||||
enum State { kBoundary, kPadding, kDone };
|
||||
@@ -454,6 +454,6 @@ inline HttpPathRef HttpPath::drop_front(size_t n) const {
|
||||
return HttpPathRef(*this, n);
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_HTTPUTIL_HPP_
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/net/uv/Stream.hpp"
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* A server-side HTTP connection that also accepts WebSocket upgrades.
|
||||
@@ -43,7 +43,7 @@ class HttpWebSocketServerConnection
|
||||
// Handle upgrade event
|
||||
m_helper.upgrade.connect([this] {
|
||||
// Negotiate sub-protocol
|
||||
SmallVector<std::string_view, 2> protocols{m_protocols.begin(),
|
||||
wpi::util::SmallVector<std::string_view, 2> protocols{m_protocols.begin(),
|
||||
m_protocols.end()};
|
||||
std::string_view protocol = m_helper.MatchProtocol(protocols).second;
|
||||
|
||||
@@ -118,9 +118,9 @@ class HttpWebSocketServerConnection
|
||||
|
||||
private:
|
||||
WebSocketServerHelper m_helper;
|
||||
SmallVector<std::string, 2> m_protocols;
|
||||
wpi::util::SmallVector<std::string, 2> m_protocols;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_HTTPWEBSOCKETSERVERCONNECTION_HPP_
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
std::string_view MimeTypeFromPath(std::string_view path);
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_MIMETYPES_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
class MulticastServiceAnnouncer {
|
||||
public:
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ class MulticastServiceAnnouncer {
|
||||
private:
|
||||
std::unique_ptr<Impl> pImpl;
|
||||
};
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "wpi/util/mutex.hpp"
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
class MulticastServiceResolver {
|
||||
public:
|
||||
explicit MulticastServiceResolver(std::string_view serviceType);
|
||||
@@ -95,14 +95,14 @@ class MulticastServiceResolver {
|
||||
event.Set();
|
||||
}
|
||||
}
|
||||
wpi::Event event{true};
|
||||
wpi::util::Event event{true};
|
||||
std::vector<ServiceData> queue;
|
||||
wpi::mutex mutex;
|
||||
wpi::util::mutex mutex;
|
||||
std::function<bool(const ServiceData&)> copyCallback;
|
||||
std::function<void(ServiceData&&)> moveCallback;
|
||||
std::unique_ptr<Impl> pImpl;
|
||||
};
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "wpi/net/NetworkStream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class NetworkAcceptor {
|
||||
public:
|
||||
@@ -24,6 +24,6 @@ class NetworkAcceptor {
|
||||
NetworkAcceptor& operator=(const NetworkAcceptor&) = delete;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_NETWORKACCEPTOR_HPP_
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <cstddef>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class NetworkStream {
|
||||
public:
|
||||
@@ -39,6 +39,6 @@ class NetworkStream {
|
||||
NetworkStream& operator=(const NetworkStream&) = delete;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_NETWORKSTREAM_HPP_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "wpi/net/uv/Timer.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class Logger;
|
||||
|
||||
@@ -59,8 +59,8 @@ class ParallelTcpConnector
|
||||
* @return Parallel connector
|
||||
*/
|
||||
static std::shared_ptr<ParallelTcpConnector> Create(
|
||||
wpi::uv::Loop& loop, wpi::uv::Timer::Time reconnectRate,
|
||||
wpi::Logger& logger, std::function<void(wpi::uv::Tcp& tcp)> connected,
|
||||
wpi::net::uv::Loop& loop, wpi::net::uv::Timer::Time reconnectRate,
|
||||
wpi::util::Logger& logger, std::function<void(wpi::net::uv::Tcp& tcp)> connected,
|
||||
bool ipv4Only = false) {
|
||||
if (loop.IsClosing()) {
|
||||
return nullptr;
|
||||
@@ -70,9 +70,9 @@ class ParallelTcpConnector
|
||||
ipv4Only, private_init{});
|
||||
}
|
||||
|
||||
ParallelTcpConnector(wpi::uv::Loop& loop, wpi::uv::Timer::Time reconnectRate,
|
||||
wpi::Logger& logger,
|
||||
std::function<void(wpi::uv::Tcp& tcp)> connected,
|
||||
ParallelTcpConnector(wpi::net::uv::Loop& loop, wpi::net::uv::Timer::Time reconnectRate,
|
||||
wpi::util::Logger& logger,
|
||||
std::function<void(wpi::net::uv::Tcp& tcp)> connected,
|
||||
bool ipv4Only, const private_init&);
|
||||
~ParallelTcpConnector();
|
||||
|
||||
@@ -105,24 +105,24 @@ class ParallelTcpConnector
|
||||
*
|
||||
* @param tcp connection passed to connected callback
|
||||
*/
|
||||
void Succeeded(wpi::uv::Tcp& tcp);
|
||||
void Succeeded(wpi::net::uv::Tcp& tcp);
|
||||
|
||||
private:
|
||||
bool IsConnected() const { return m_isConnected || m_servers.empty(); }
|
||||
void Connect();
|
||||
void CancelAll(wpi::uv::Tcp* except = nullptr);
|
||||
void CancelAll(wpi::net::uv::Tcp* except = nullptr);
|
||||
|
||||
wpi::uv::Loop& m_loop;
|
||||
wpi::Logger& m_logger;
|
||||
wpi::uv::Timer::Time m_reconnectRate;
|
||||
wpi::net::uv::Loop& m_loop;
|
||||
wpi::util::Logger& m_logger;
|
||||
wpi::net::uv::Timer::Time m_reconnectRate;
|
||||
bool m_ipv4Only;
|
||||
std::function<void(wpi::uv::Tcp& tcp)> m_connected;
|
||||
std::shared_ptr<wpi::uv::Timer> m_reconnectTimer;
|
||||
std::function<void(wpi::net::uv::Tcp& tcp)> m_connected;
|
||||
std::shared_ptr<wpi::net::uv::Timer> m_reconnectTimer;
|
||||
std::vector<std::pair<std::string, unsigned int>> m_servers;
|
||||
std::vector<std::weak_ptr<wpi::uv::GetAddrInfoReq>> m_resolvers;
|
||||
std::vector<std::pair<sockaddr_storage, std::weak_ptr<wpi::uv::Tcp>>>
|
||||
std::vector<std::weak_ptr<wpi::net::uv::GetAddrInfoReq>> m_resolvers;
|
||||
std::vector<std::pair<sockaddr_storage, std::weak_ptr<wpi::net::uv::Tcp>>>
|
||||
m_attempts;
|
||||
bool m_isConnected{false};
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* Forward ports to another host. This is primarily useful for accessing
|
||||
@@ -54,6 +54,6 @@ class PortForwarder {
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_PORTFORWARDER_HPP_
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
int SocketErrno();
|
||||
|
||||
@@ -17,6 +17,6 @@ inline std::string SocketStrerror() {
|
||||
return SocketStrerror(SocketErrno());
|
||||
}
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_SOCKETERROR_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class Logger;
|
||||
|
||||
@@ -20,11 +20,11 @@ class UDPClient {
|
||||
int m_lsd;
|
||||
int m_port;
|
||||
std::string m_address;
|
||||
Logger& m_logger;
|
||||
wpi::util::Logger& m_logger;
|
||||
|
||||
public:
|
||||
explicit UDPClient(Logger& logger);
|
||||
UDPClient(std::string_view address, Logger& logger);
|
||||
explicit UDPClient(wpi::util::Logger& logger);
|
||||
UDPClient(std::string_view address, wpi::util::Logger& logger);
|
||||
UDPClient(const UDPClient& other) = delete;
|
||||
UDPClient(UDPClient&& other);
|
||||
~UDPClient();
|
||||
@@ -40,10 +40,10 @@ class UDPClient {
|
||||
int send(std::string_view data, std::string_view server, int port);
|
||||
int receive(uint8_t* data_received, int receive_len);
|
||||
int receive(uint8_t* data_received, int receive_len,
|
||||
SmallVectorImpl<char>* addr_received, int* port_received);
|
||||
wpi::util::SmallVectorImpl<char>* addr_received, int* port_received);
|
||||
int set_timeout(double timeout);
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UDPCLIENT_HPP_
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "wpi/net/http_parser.hpp"
|
||||
#include "wpi/util/StringExtras.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* Parses a URL into its constituent components.
|
||||
@@ -53,34 +53,34 @@ class UrlParser {
|
||||
}
|
||||
|
||||
std::string_view GetSchema() const {
|
||||
return wpi::substr(m_data, m_url.field_data[UF_SCHEMA].off,
|
||||
return wpi::util::substr(m_data, m_url.field_data[UF_SCHEMA].off,
|
||||
m_url.field_data[UF_SCHEMA].len);
|
||||
}
|
||||
|
||||
std::string_view GetHost() const {
|
||||
return wpi::substr(m_data, m_url.field_data[UF_HOST].off,
|
||||
return wpi::util::substr(m_data, m_url.field_data[UF_HOST].off,
|
||||
m_url.field_data[UF_HOST].len);
|
||||
}
|
||||
|
||||
unsigned int GetPort() const { return m_url.port; }
|
||||
|
||||
std::string_view GetPath() const {
|
||||
return wpi::substr(m_data, m_url.field_data[UF_PATH].off,
|
||||
return wpi::util::substr(m_data, m_url.field_data[UF_PATH].off,
|
||||
m_url.field_data[UF_PATH].len);
|
||||
}
|
||||
|
||||
std::string_view GetQuery() const {
|
||||
return wpi::substr(m_data, m_url.field_data[UF_QUERY].off,
|
||||
return wpi::util::substr(m_data, m_url.field_data[UF_QUERY].off,
|
||||
m_url.field_data[UF_QUERY].len);
|
||||
}
|
||||
|
||||
std::string_view GetFragment() const {
|
||||
return wpi::substr(m_data, m_url.field_data[UF_FRAGMENT].off,
|
||||
return wpi::util::substr(m_data, m_url.field_data[UF_FRAGMENT].off,
|
||||
m_url.field_data[UF_FRAGMENT].len);
|
||||
}
|
||||
|
||||
std::string_view GetUserInfo() const {
|
||||
return wpi::substr(m_data, m_url.field_data[UF_USERINFO].off,
|
||||
return wpi::util::substr(m_data, m_url.field_data[UF_USERINFO].off,
|
||||
m_url.field_data[UF_USERINFO].len);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,6 @@ class UrlParser {
|
||||
http_parser_url m_url;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_URLPARSER_HPP_
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* A web server using the HTTP protocol.
|
||||
@@ -53,6 +53,6 @@ class WebServer {
|
||||
std::unique_ptr<Impl> m_impl;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_WEBSERVER_HPP_
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/util/Signal.h"
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
namespace uv {
|
||||
class Stream;
|
||||
@@ -466,7 +466,7 @@ class WebSocket : public std::enable_shared_from_this<WebSocket> {
|
||||
* Open event. Emitted when the connection is open and ready to communicate.
|
||||
* The parameter is the selected subprotocol.
|
||||
*/
|
||||
sig::Signal<std::string_view> open;
|
||||
wpi::util::sig::Signal<std::string_view> open;
|
||||
|
||||
/**
|
||||
* Close event. Emitted when the connection is closed. The first parameter
|
||||
@@ -474,32 +474,32 @@ class WebSocket : public std::enable_shared_from_this<WebSocket> {
|
||||
* has been closed. The second parameter is a human-readable string
|
||||
* explaining the reason why the connection has been closed.
|
||||
*/
|
||||
sig::Signal<uint16_t, std::string_view> closed;
|
||||
wpi::util::sig::Signal<uint16_t, std::string_view> closed;
|
||||
|
||||
/**
|
||||
* Text message event. Emitted when a text message is received.
|
||||
* The first parameter is the data, the second parameter is true if the
|
||||
* data is the last fragment of the message.
|
||||
*/
|
||||
sig::Signal<std::string_view, bool> text;
|
||||
wpi::util::sig::Signal<std::string_view, bool> text;
|
||||
|
||||
/**
|
||||
* Binary message event. Emitted when a binary message is received.
|
||||
* The first parameter is the data, the second parameter is true if the
|
||||
* data is the last fragment of the message.
|
||||
*/
|
||||
sig::Signal<std::span<const uint8_t>, bool> binary;
|
||||
wpi::util::sig::Signal<std::span<const uint8_t>, bool> binary;
|
||||
|
||||
/**
|
||||
* Ping event. Emitted when a ping message is received. A pong message is
|
||||
* automatically sent in response, so this is simply a notification.
|
||||
*/
|
||||
sig::Signal<std::span<const uint8_t>> ping;
|
||||
wpi::util::sig::Signal<std::span<const uint8_t>> ping;
|
||||
|
||||
/**
|
||||
* Pong event. Emitted when a pong message is received.
|
||||
*/
|
||||
sig::Signal<std::span<const uint8_t>> pong;
|
||||
wpi::util::sig::Signal<std::span<const uint8_t>> pong;
|
||||
|
||||
private:
|
||||
// user data
|
||||
@@ -527,10 +527,10 @@ class WebSocket : public std::enable_shared_from_this<WebSocket> {
|
||||
|
||||
// incoming message buffers/state
|
||||
uint64_t m_lastReceivedTime = 0;
|
||||
SmallVector<uint8_t, 14> m_header;
|
||||
wpi::util::SmallVector<uint8_t, 14> m_header;
|
||||
size_t m_headerSize = 0;
|
||||
SmallVector<uint8_t, 1024> m_payload;
|
||||
SmallVector<uint8_t, 64> m_controlPayload;
|
||||
wpi::util::SmallVector<uint8_t, 1024> m_payload;
|
||||
wpi::util::SmallVector<uint8_t, 64> m_controlPayload;
|
||||
size_t m_frameStart = 0;
|
||||
uint64_t m_frameSize = UINT64_MAX;
|
||||
uint8_t m_fragmentOpcode = 0;
|
||||
@@ -559,6 +559,6 @@ class WebSocket : public std::enable_shared_from_this<WebSocket> {
|
||||
const std::function<void(std::span<uv::Buffer>, uv::Error)>& callback);
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_WEBSOCKET_HPP_
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "wpi/util/SmallString.hpp"
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
namespace uv {
|
||||
class Stream;
|
||||
@@ -97,14 +97,14 @@ class WebSocketServerHelper {
|
||||
/**
|
||||
* Upgrade event. Call Accept() to accept the upgrade.
|
||||
*/
|
||||
sig::Signal<> upgrade;
|
||||
wpi::util::sig::Signal<> upgrade;
|
||||
|
||||
private:
|
||||
bool m_gotHost = false;
|
||||
bool m_websocket = false;
|
||||
SmallVector<std::string, 2> m_protocols;
|
||||
SmallString<64> m_key;
|
||||
SmallString<16> m_version;
|
||||
wpi::util::SmallVector<std::string, 2> m_protocols;
|
||||
wpi::util::SmallString<64> m_key;
|
||||
wpi::util::SmallString<16> m_version;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -169,22 +169,22 @@ class WebSocketServer : public std::enable_shared_from_this<WebSocketServer> {
|
||||
/**
|
||||
* Connected event. First parameter is the URL, second is the websocket.
|
||||
*/
|
||||
sig::Signal<std::string_view, WebSocket&> connected;
|
||||
wpi::util::sig::Signal<std::string_view, WebSocket&> connected;
|
||||
|
||||
private:
|
||||
uv::Stream& m_stream;
|
||||
HttpParser m_req{HttpParser::kRequest};
|
||||
WebSocketServerHelper m_helper;
|
||||
SmallVector<std::string, 2> m_protocols;
|
||||
wpi::util::SmallVector<std::string, 2> m_protocols;
|
||||
ServerOptions m_options;
|
||||
bool m_aborted = false;
|
||||
sig::ScopedConnection m_dataConn;
|
||||
sig::ScopedConnection m_errorConn;
|
||||
sig::ScopedConnection m_endConn;
|
||||
wpi::util::sig::ScopedConnection m_dataConn;
|
||||
wpi::util::sig::ScopedConnection m_errorConn;
|
||||
wpi::util::sig::ScopedConnection m_endConn;
|
||||
|
||||
void Abort(uint16_t code, std::string_view reason);
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_WEBSOCKETSERVER_HPP_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/util/SafeThread.hpp"
|
||||
#include "wpi/util/future.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
namespace detail {
|
||||
|
||||
@@ -89,14 +89,14 @@ struct WorkerThreadRequest {
|
||||
};
|
||||
|
||||
template <typename R, typename... T>
|
||||
class WorkerThreadThread : public SafeThread {
|
||||
class WorkerThreadThread : public wpi::util::SafeThread {
|
||||
public:
|
||||
using Request = WorkerThreadRequest<R, T...>;
|
||||
|
||||
void Main() override;
|
||||
|
||||
std::vector<Request> m_requests;
|
||||
PromiseFactory<R> m_promises;
|
||||
wpi::util::PromiseFactory<R> m_promises;
|
||||
detail::WorkerThreadAsync<R> m_async;
|
||||
};
|
||||
|
||||
@@ -228,7 +228,7 @@ class WorkerThread<R(T...)> final {
|
||||
* @param u Arguments to work function
|
||||
*/
|
||||
template <typename... U>
|
||||
future<R> QueueWork(WorkFunction work, U&&... u) {
|
||||
wpi::util::future<R> QueueWork(WorkFunction work, U&&... u) {
|
||||
if (auto thr = m_owner.GetThread()) {
|
||||
// create the future
|
||||
uint64_t req = thr->m_promises.CreateRequest();
|
||||
@@ -245,7 +245,7 @@ class WorkerThread<R(T...)> final {
|
||||
}
|
||||
|
||||
// XXX: is this the right thing to do?
|
||||
return future<R>();
|
||||
return wpi::util::future<R>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -277,9 +277,9 @@ class WorkerThread<R(T...)> final {
|
||||
}
|
||||
|
||||
private:
|
||||
SafeThreadOwner<Thread> m_owner;
|
||||
wpi::util::SafeThreadOwner<Thread> m_owner;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_WORKERTHREAD_HPP_
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
|
||||
std::string GetHostname();
|
||||
std::string_view GetHostname(SmallVectorImpl<char>& name);
|
||||
} // namespace wpi
|
||||
std::string_view GetHostname(wpi::util::SmallVectorImpl<char>& name);
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_HOSTNAME_HPP_
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
# define HTTP_MAX_HEADER_SIZE (80*1024)
|
||||
#endif
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
struct http_parser;
|
||||
struct http_parser_settings;
|
||||
@@ -273,7 +273,7 @@ enum http_errno {
|
||||
|
||||
|
||||
/* Get an http_errno value from an http_parser */
|
||||
#define HTTP_PARSER_ERRNO(p) ((::wpi::http_errno) (p)->http_errno)
|
||||
#define HTTP_PARSER_ERRNO(p) ((::wpi::net::http_errno) (p)->http_errno)
|
||||
|
||||
|
||||
struct http_parser {
|
||||
@@ -416,6 +416,6 @@ void http_parser_pause(http_parser *parser, int paused);
|
||||
/* Checks if this is the final chunk of the body. */
|
||||
int http_body_is_final(const http_parser *parser);
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
#include "wpi/util/raw_istream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class NetworkStream;
|
||||
|
||||
class raw_socket_istream : public raw_istream {
|
||||
class raw_socket_istream : public wpi::util::raw_istream {
|
||||
public:
|
||||
explicit raw_socket_istream(NetworkStream& stream, int timeout = 0)
|
||||
: m_stream(stream), m_timeout(timeout) {}
|
||||
@@ -26,6 +26,6 @@ class raw_socket_istream : public raw_istream {
|
||||
int m_timeout;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_RAW_SOCKET_ISTREAM_HPP_
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
class NetworkStream;
|
||||
|
||||
class raw_socket_ostream : public raw_ostream {
|
||||
class raw_socket_ostream : public wpi::util::raw_ostream {
|
||||
public:
|
||||
raw_socket_ostream(NetworkStream& stream, bool shouldClose)
|
||||
: m_stream(stream), m_shouldClose(shouldClose) {}
|
||||
@@ -34,6 +34,6 @@ class raw_socket_ostream : public raw_ostream {
|
||||
bool m_shouldClose;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_RAW_SOCKET_OSTREAM_HPP_
|
||||
|
||||
@@ -13,14 +13,14 @@
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
#include "wpi/util/raw_ostream.hpp"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
|
||||
/**
|
||||
* raw_ostream style output to a SmallVector of uv::Buffer buffers. Fixed-size
|
||||
* wpi::util::raw_ostream style output to a wpi::util::SmallVector of uv::Buffer buffers. Fixed-size
|
||||
* buffers are allocated and appended as necessary to fit the data being output.
|
||||
* The SmallVector need not be empty at start.
|
||||
* The wpi::util::SmallVector need not be empty at start.
|
||||
*/
|
||||
class raw_uv_ostream : public raw_ostream {
|
||||
class raw_uv_ostream : public wpi::util::raw_ostream {
|
||||
public:
|
||||
/**
|
||||
* Construct a new raw_uv_ostream.
|
||||
@@ -28,7 +28,7 @@ class raw_uv_ostream : public raw_ostream {
|
||||
* @param allocSize Size to allocate for each buffer; allocation will be
|
||||
* performed using Buffer::Allocate().
|
||||
*/
|
||||
raw_uv_ostream(SmallVectorImpl<uv::Buffer>& bufs, size_t allocSize)
|
||||
raw_uv_ostream(wpi::util::SmallVectorImpl<uv::Buffer>& bufs, size_t allocSize)
|
||||
: m_bufs(bufs), m_alloc([=] { return uv::Buffer::Allocate(allocSize); }) {
|
||||
SetUnbuffered();
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class raw_uv_ostream : public raw_ostream {
|
||||
* @param bufs Buffers vector. NOT cleared on construction.
|
||||
* @param alloc Allocator.
|
||||
*/
|
||||
raw_uv_ostream(SmallVectorImpl<uv::Buffer>& bufs,
|
||||
raw_uv_ostream(wpi::util::SmallVectorImpl<uv::Buffer>& bufs,
|
||||
std::function<uv::Buffer()> alloc)
|
||||
: m_bufs(bufs), m_alloc(std::move(alloc)) {
|
||||
SetUnbuffered();
|
||||
@@ -62,13 +62,13 @@ class raw_uv_ostream : public raw_ostream {
|
||||
void write_impl(const char* data, size_t len) override;
|
||||
uint64_t current_pos() const override;
|
||||
|
||||
SmallVectorImpl<uv::Buffer>& m_bufs;
|
||||
wpi::util::SmallVectorImpl<uv::Buffer>& m_bufs;
|
||||
std::function<uv::Buffer()> m_alloc;
|
||||
|
||||
// How much allocated space is left in the current buffer.
|
||||
size_t m_left = 0;
|
||||
};
|
||||
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_RAW_UV_OSTREAM_HPP_
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/util/Signal.h"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
/**
|
||||
* Async handle.
|
||||
@@ -121,10 +121,10 @@ class Async final : public HandleImpl<Async<T...>, uv_async_t> {
|
||||
/**
|
||||
* Signal generated (on event loop thread) when the async event occurs.
|
||||
*/
|
||||
sig::Signal<T...> wakeup;
|
||||
wpi::util::sig::Signal<T...> wakeup;
|
||||
|
||||
private:
|
||||
wpi::mutex m_mutex;
|
||||
wpi::util::mutex m_mutex;
|
||||
std::vector<std::tuple<T...>> m_data;
|
||||
std::weak_ptr<Loop> m_loop;
|
||||
};
|
||||
@@ -190,12 +190,12 @@ class Async<> final : public HandleImpl<Async<>, uv_async_t> {
|
||||
/**
|
||||
* Signal generated (on event loop thread) when the async event occurs.
|
||||
*/
|
||||
sig::Signal<> wakeup;
|
||||
wpi::util::sig::Signal<> wakeup;
|
||||
|
||||
private:
|
||||
std::weak_ptr<Loop> m_loop;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_ASYNC_HPP_
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
#include "wpi/util/future.hpp"
|
||||
#include "wpi/util/mutex.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
template <typename T>
|
||||
class AsyncFunction;
|
||||
@@ -38,7 +38,7 @@ class AsyncFunction<R(T...)> final
|
||||
|
||||
public:
|
||||
AsyncFunction(const std::shared_ptr<Loop>& loop,
|
||||
std::function<void(promise<R>, T...)> func, const private_init&)
|
||||
std::function<void(wpi::util::promise<R>, T...)> func, const private_init&)
|
||||
: wakeup{std::move(func)}, m_loop{loop} {}
|
||||
~AsyncFunction() noexcept override {
|
||||
if (auto loop = m_loop.lock()) {
|
||||
@@ -58,7 +58,7 @@ class AsyncFunction<R(T...)> final
|
||||
* wakeup function, a default-constructed value is "returned".
|
||||
*/
|
||||
static std::shared_ptr<AsyncFunction> Create(
|
||||
Loop& loop, std::function<void(promise<R>, T...)> func = nullptr) {
|
||||
Loop& loop, std::function<void(wpi::util::promise<R>, T...)> func = nullptr) {
|
||||
return Create(loop.shared_from_this(), std::move(func));
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class AsyncFunction<R(T...)> final
|
||||
*/
|
||||
static std::shared_ptr<AsyncFunction> Create(
|
||||
const std::shared_ptr<Loop>& loop,
|
||||
std::function<void(promise<R>, T...)> func = nullptr) {
|
||||
std::function<void(wpi::util::promise<R>, T...)> func = nullptr) {
|
||||
if (loop->IsClosing()) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class AsyncFunction<R(T...)> final
|
||||
* destroyed while waiting for a result.
|
||||
*/
|
||||
template <typename... U>
|
||||
future<R> Call(U&&... u) {
|
||||
wpi::util::future<R> Call(U&&... u) {
|
||||
// create the future
|
||||
uint64_t req = m_promises.CreateRequest();
|
||||
|
||||
@@ -157,22 +157,22 @@ class AsyncFunction<R(T...)> final
|
||||
}
|
||||
|
||||
template <typename... U>
|
||||
future<R> operator()(U&&... u) {
|
||||
wpi::util::future<R> operator()(U&&... u) {
|
||||
return Call(std::forward<U>(u)...);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function called (on event loop thread) when the async is called.
|
||||
*/
|
||||
std::function<void(promise<R>, T...)> wakeup;
|
||||
std::function<void(wpi::util::promise<R>, T...)> wakeup;
|
||||
|
||||
private:
|
||||
wpi::mutex m_mutex;
|
||||
wpi::util::mutex m_mutex;
|
||||
std::vector<std::pair<uint64_t, std::tuple<T...>>> m_params;
|
||||
PromiseFactory<R> m_promises;
|
||||
wpi::util::PromiseFactory<R> m_promises;
|
||||
std::weak_ptr<Loop> m_loop;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_ASYNCFUNCTION_HPP_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
/**
|
||||
* Data buffer. Convenience wrapper around uv_buf_t.
|
||||
@@ -167,10 +167,10 @@ class SimpleBufferPool {
|
||||
size_t Remaining() const { return m_pool.size(); }
|
||||
|
||||
private:
|
||||
SmallVector<Buffer, DEPTH> m_pool;
|
||||
wpi::util::SmallVector<Buffer, DEPTH> m_pool;
|
||||
size_t m_size; // NOLINT
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_BUFFER_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -57,9 +57,9 @@ class Check final : public HandleImpl<Check, uv_check_t> {
|
||||
/**
|
||||
* Signal generated once per loop iteration after polling for I/O.
|
||||
*/
|
||||
sig::Signal<> check;
|
||||
wpi::util::sig::Signal<> check;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_CHECK_HPP_
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
/**
|
||||
* Error code.
|
||||
@@ -41,6 +41,6 @@ class Error {
|
||||
int m_err{0};
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_ERROR_HPP_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -71,9 +71,9 @@ class FsEvent final : public HandleImpl<FsEvent, uv_fs_event_t> {
|
||||
* relative to that directory). The second parameter is an ORed mask of
|
||||
* UV_RENAME and UV_CHANGE.
|
||||
*/
|
||||
sig::Signal<const char*, int> fsEvent;
|
||||
wpi::util::sig::Signal<const char*, int> fsEvent;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_FSEVENT_HPP_
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include "wpi/net/uv/Request.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -34,7 +34,7 @@ class GetAddrInfoReq : public RequestImpl<GetAddrInfoReq, uv_getaddrinfo_t> {
|
||||
* Resolved lookup signal.
|
||||
* Parameter is resolved address info.
|
||||
*/
|
||||
sig::Signal<const addrinfo&> resolved;
|
||||
wpi::util::sig::Signal<const addrinfo&> resolved;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -115,6 +115,6 @@ inline void GetAddrInfo(const std::shared_ptr<Loop>& loop,
|
||||
GetAddrInfo(*loop, std::move(callback), node, service, hints);
|
||||
}
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_GETADDRINFO_HPP_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/net/uv/Request.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -33,7 +33,7 @@ class GetNameInfoReq : public RequestImpl<GetNameInfoReq, uv_getnameinfo_t> {
|
||||
* Resolved lookup signal.
|
||||
* Parameters are hostname and service.
|
||||
*/
|
||||
sig::Signal<const char*, const char*> resolved;
|
||||
wpi::util::sig::Signal<const char*, const char*> resolved;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -222,6 +222,6 @@ inline void GetNameInfo6(const std::shared_ptr<Loop>& loop,
|
||||
return GetNameInfo6(*loop, std::move(callback), ip, port, flags);
|
||||
}
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_GETNAMEINFO_HPP_
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
#include "wpi/net/uv/Loop.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi {
|
||||
namespace wpi::net {
|
||||
class Logger;
|
||||
} // namespace wpi
|
||||
} // namespace wpi::net
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
/**
|
||||
* Handle.
|
||||
@@ -226,23 +226,23 @@ class Handle : public std::enable_shared_from_this<Handle> {
|
||||
* Sets logger.
|
||||
* @param logger Logger
|
||||
*/
|
||||
void SetLogger(Logger* logger) { m_logger = logger; }
|
||||
void SetLogger(wpi::util::Logger* logger) { m_logger = logger; }
|
||||
|
||||
/**
|
||||
* Gets logger.
|
||||
* @return Logger, or nullptr if none set
|
||||
*/
|
||||
Logger* GetLogger() const { return m_logger; }
|
||||
wpi::util::Logger* GetLogger() const { return m_logger; }
|
||||
|
||||
/**
|
||||
* Error signal
|
||||
*/
|
||||
sig::Signal<Error> error;
|
||||
wpi::util::sig::Signal<Error> error;
|
||||
|
||||
/**
|
||||
* Closed signal
|
||||
*/
|
||||
sig::Signal<> closed;
|
||||
wpi::util::sig::Signal<> closed;
|
||||
|
||||
/**
|
||||
* Report an error.
|
||||
@@ -279,7 +279,7 @@ class Handle : public std::enable_shared_from_this<Handle> {
|
||||
std::function<Buffer(size_t)> m_allocBuf{&Buffer::Allocate};
|
||||
std::function<void(Buffer&)> m_freeBuf{&DefaultFreeBuf};
|
||||
std::shared_ptr<void> m_data;
|
||||
Logger* m_logger = nullptr;
|
||||
wpi::util::Logger* m_logger = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -309,6 +309,6 @@ class HandleImpl : public Handle {
|
||||
HandleImpl() : Handle{static_cast<uv_handle_t*>(std::malloc(sizeof(U)))} {}
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_HANDLE_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -66,9 +66,9 @@ class Idle final : public HandleImpl<Idle, uv_idle_t> {
|
||||
/**
|
||||
* Signal generated once per loop iteration prior to Prepare signals.
|
||||
*/
|
||||
sig::Signal<> idle;
|
||||
wpi::util::sig::Signal<> idle;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_IDLE_HPP_
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "wpi/util/Signal.h"
|
||||
#include "wpi/util/function_ref.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Handle;
|
||||
|
||||
@@ -186,7 +186,7 @@ class Loop final : public std::enable_shared_from_this<Loop> {
|
||||
*
|
||||
* @param callback A function to be invoked once for each active handle.
|
||||
*/
|
||||
void Walk(function_ref<void(Handle&)> callback);
|
||||
void Walk(wpi::util::function_ref<void(Handle&)> callback);
|
||||
|
||||
/**
|
||||
* Reinitialize any kernel state necessary in the child process after
|
||||
@@ -247,7 +247,7 @@ class Loop final : public std::enable_shared_from_this<Loop> {
|
||||
/**
|
||||
* Error signal
|
||||
*/
|
||||
sig::Signal<Error> error;
|
||||
wpi::util::sig::Signal<Error> error;
|
||||
|
||||
/**
|
||||
* Reports error.
|
||||
@@ -263,6 +263,6 @@ class Loop final : public std::enable_shared_from_this<Loop> {
|
||||
bool m_closing = false;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_LOOP_HPP_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/net/uv/Stream.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class NetworkStream;
|
||||
|
||||
@@ -32,7 +32,7 @@ class ConnectReq : public RequestImpl<ConnectReq, uv_connect_t> {
|
||||
/**
|
||||
* Connection completed signal.
|
||||
*/
|
||||
sig::Signal<> connected;
|
||||
wpi::util::sig::Signal<> connected;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ class NetworkStream : public Stream {
|
||||
/**
|
||||
* Signal generated when an incoming connection is received.
|
||||
*/
|
||||
sig::Signal<> connection;
|
||||
wpi::util::sig::Signal<> connection;
|
||||
|
||||
protected:
|
||||
explicit NetworkStream(uv_stream_t* uv_stream) : Stream{uv_stream} {}
|
||||
@@ -148,6 +148,6 @@ class NetworkStreamImpl : public NetworkStream {
|
||||
: NetworkStream{static_cast<uv_stream_t*>(std::malloc(sizeof(U)))} {}
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_NETWORKSTREAM_HPP_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
#include "wpi/net/uv/NetworkStream.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
class PipeConnectReq;
|
||||
@@ -203,6 +203,6 @@ class PipeConnectReq : public ConnectReq {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_PIPE_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -105,7 +105,7 @@ class Poll final : public HandleImpl<Poll, uv_poll_t> {
|
||||
/**
|
||||
* Signal generated when a poll event occurs.
|
||||
*/
|
||||
sig::Signal<int> pollEvent;
|
||||
wpi::util::sig::Signal<int> pollEvent;
|
||||
|
||||
private:
|
||||
struct ReuseData {
|
||||
@@ -117,6 +117,6 @@ class Poll final : public HandleImpl<Poll, uv_poll_t> {
|
||||
std::unique_ptr<ReuseData> m_reuseData;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_POLL_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -57,9 +57,9 @@ class Prepare final : public HandleImpl<Prepare, uv_prepare_t> {
|
||||
/**
|
||||
* Signal generated once per loop iteration prior to polling for I/O.
|
||||
*/
|
||||
sig::Signal<> prepare;
|
||||
wpi::util::sig::Signal<> prepare;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_PREPARE_HPP_
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/util/Signal.h"
|
||||
#include "wpi/util/SmallVector.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
class Pipe;
|
||||
@@ -70,7 +70,7 @@ class Process final : public HandleImpl<Process, uv_process_t> {
|
||||
m_data.str = m_strData.c_str();
|
||||
}
|
||||
|
||||
/*implicit*/ Option(const SmallVectorImpl<char>& arg) // NOLINT
|
||||
/*implicit*/ Option(const wpi::util::SmallVectorImpl<char>& arg) // NOLINT
|
||||
: m_strData(arg.data(), arg.size()) {
|
||||
m_data.str = m_strData.c_str();
|
||||
}
|
||||
@@ -302,9 +302,9 @@ class Process final : public HandleImpl<Process, uv_process_t> {
|
||||
* Signal generated when the process exits. The parameters are the exit
|
||||
* status and the signal that caused the process to terminate, if any.
|
||||
*/
|
||||
sig::Signal<int64_t, int> exited;
|
||||
wpi::util::sig::Signal<int64_t, int> exited;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_PROCESS_HPP_
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "wpi/net/uv/Error.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
/**
|
||||
* Request. Requests are not moveable or copyable.
|
||||
@@ -166,6 +166,6 @@ class RequestImpl : public Request {
|
||||
U m_uv_req;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_REQUEST_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -71,9 +71,9 @@ class Signal final : public HandleImpl<Signal, uv_signal_t> {
|
||||
/**
|
||||
* Signal generated when a signal occurs.
|
||||
*/
|
||||
sig::Signal<int> signal;
|
||||
wpi::util::sig::Signal<int> signal;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_SIGNAL_HPP_
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "wpi/net/uv/Request.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Stream;
|
||||
|
||||
@@ -37,7 +37,7 @@ class ShutdownReq : public RequestImpl<ShutdownReq, uv_shutdown_t> {
|
||||
/**
|
||||
* Shutdown completed signal.
|
||||
*/
|
||||
sig::Signal<> complete;
|
||||
wpi::util::sig::Signal<> complete;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ class WriteReq : public RequestImpl<WriteReq, uv_write_t> {
|
||||
* Write completed signal. This is called even if an error occurred.
|
||||
* @param err error value
|
||||
*/
|
||||
sig::Signal<Error> finish;
|
||||
wpi::util::sig::Signal<Error> finish;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -293,12 +293,12 @@ class Stream : public Handle {
|
||||
/**
|
||||
* Signal generated when data was read on a stream.
|
||||
*/
|
||||
sig::Signal<Buffer&, size_t> data;
|
||||
wpi::util::sig::Signal<Buffer&, size_t> data;
|
||||
|
||||
/**
|
||||
* Signal generated when no more read data is available.
|
||||
*/
|
||||
sig::Signal<> end;
|
||||
wpi::util::sig::Signal<> end;
|
||||
|
||||
protected:
|
||||
explicit Stream(uv_stream_t* uv_stream)
|
||||
@@ -329,6 +329,6 @@ class StreamImpl : public Stream {
|
||||
StreamImpl() : Stream{static_cast<uv_stream_t*>(std::malloc(sizeof(U)))} {}
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_STREAM_HPP_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "wpi/net/uv/NetworkStream.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
class TcpConnectReq;
|
||||
@@ -366,6 +366,6 @@ class TcpConnectReq : public ConnectReq {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_TCP_HPP_
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "wpi/net/uv/Handle.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -136,9 +136,9 @@ class Timer final : public HandleImpl<Timer, uv_timer_t> {
|
||||
/**
|
||||
* Signal generated when the timeout event occurs.
|
||||
*/
|
||||
sig::Signal<> timeout;
|
||||
wpi::util::sig::Signal<> timeout;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_TIMER_HPP_
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include "wpi/net/uv/Stream.hpp"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
class Tty;
|
||||
@@ -80,6 +80,6 @@ class Tty final : public StreamImpl<Tty, uv_tty_t> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_TTY_HPP_
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "wpi/net/uv/Request.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
class Udp;
|
||||
@@ -35,7 +35,7 @@ class UdpSendReq : public RequestImpl<UdpSendReq, uv_udp_send_t> {
|
||||
* Send completed signal. This is called even if an error occurred.
|
||||
* @param err error value
|
||||
*/
|
||||
sig::Signal<Error> complete;
|
||||
wpi::util::sig::Signal<Error> complete;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -390,9 +390,9 @@ class Udp final : public HandleImpl<Udp, uv_udp_t> {
|
||||
* Signal generated for each incoming datagram. Parameters are the buffer,
|
||||
* the number of bytes received, the address of the sender, and flags.
|
||||
*/
|
||||
sig::Signal<Buffer&, size_t, const sockaddr&, unsigned> received;
|
||||
wpi::util::sig::Signal<Buffer&, size_t, const sockaddr&, unsigned> received;
|
||||
};
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_UDP_HPP_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "wpi/net/uv/Request.hpp"
|
||||
#include "wpi/util/Signal.h"
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
class Loop;
|
||||
|
||||
@@ -31,13 +31,13 @@ class WorkReq : public RequestImpl<WorkReq, uv_work_t> {
|
||||
/**
|
||||
* Function(s) that will be run on the thread pool.
|
||||
*/
|
||||
sig::Signal<> work;
|
||||
wpi::util::sig::Signal<> work;
|
||||
|
||||
/**
|
||||
* Function(s) that will be run on the loop thread after the work on the
|
||||
* thread pool has been completed by the work callback.
|
||||
*/
|
||||
sig::Signal<> afterWork;
|
||||
wpi::util::sig::Signal<> afterWork;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,6 +88,6 @@ inline void QueueWork(const std::shared_ptr<Loop>& loop,
|
||||
QueueWork(*loop, std::move(work), std::move(afterWork));
|
||||
}
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_WORK_HPP_
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#pragma comment(lib, "Ws2_32.lib")
|
||||
#endif
|
||||
|
||||
namespace wpi::uv {
|
||||
namespace wpi::net::uv {
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
@@ -153,6 +153,6 @@ int NameToAddr(std::string_view ip, in_addr* addr);
|
||||
*/
|
||||
int NameToAddr(std::string_view ip, in6_addr* addr);
|
||||
|
||||
} // namespace wpi::uv
|
||||
} // namespace wpi::net::uv
|
||||
|
||||
#endif // WPINET_WPINET_SRC_MAIN_NATIVE_INCLUDE_WPI_NET_UV_UTIL_HPP_
|
||||
|
||||
Reference in New Issue
Block a user