mirror of https://github.com/AxioDL/jbus.git
Merge pull request #1 from lioncash/explicit
General: Make operator bool overloads and single-arg constructors exp…
This commit is contained in:
commit
87cbb52a33
|
@ -91,7 +91,7 @@ class Endpoint {
|
||||||
return x34_bytesSent * 100 / x64_totalBytes;
|
return x34_bytesSent * 100 / x64_totalBytes;
|
||||||
}
|
}
|
||||||
bool isDone() const { return !x14_callback; }
|
bool isDone() const { return !x14_callback; }
|
||||||
operator bool() const { return m_initialized; }
|
explicit operator bool() const { return m_initialized; }
|
||||||
};
|
};
|
||||||
|
|
||||||
friend class ThreadLocalEndpoint;
|
friend class ThreadLocalEndpoint;
|
||||||
|
|
|
@ -10,8 +10,8 @@ namespace jbus {
|
||||||
|
|
||||||
/** Server interface for accepting incoming connections from GBA emulator instances. */
|
/** Server interface for accepting incoming connections from GBA emulator instances. */
|
||||||
class Listener {
|
class Listener {
|
||||||
net::Socket m_dataServer = {false};
|
net::Socket m_dataServer{false};
|
||||||
net::Socket m_clockServer = {false};
|
net::Socket m_clockServer{false};
|
||||||
std::thread m_listenerThread;
|
std::thread m_listenerThread;
|
||||||
std::mutex m_queueLock;
|
std::mutex m_queueLock;
|
||||||
std::queue<std::unique_ptr<Endpoint>> m_endpointQueue;
|
std::queue<std::unique_ptr<Endpoint>> m_endpointQueue;
|
||||||
|
|
|
@ -24,10 +24,10 @@ class IPAddress {
|
||||||
void resolve(const std::string& address);
|
void resolve(const std::string& address);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
IPAddress(const std::string& address) { resolve(address); }
|
explicit IPAddress(const std::string& address) { resolve(address); }
|
||||||
|
|
||||||
uint32_t toInteger() const;
|
uint32_t toInteger() const;
|
||||||
operator bool() const { return m_valid; }
|
explicit operator bool() const { return m_valid; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Server-oriented TCP socket class derived from SFML */
|
/** Server-oriented TCP socket class derived from SFML */
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
static EResult LastWSAError();
|
static EResult LastWSAError();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Socket(bool blocking) : m_isBlocking(blocking) {}
|
explicit Socket(bool blocking) : m_isBlocking(blocking) {}
|
||||||
~Socket() { close(); }
|
~Socket() { close(); }
|
||||||
|
|
||||||
Socket(const Socket& other) = delete;
|
Socket(const Socket& other) = delete;
|
||||||
|
@ -76,7 +76,7 @@ public:
|
||||||
EResult recv(void* buf, size_t len, size_t& transferred);
|
EResult recv(void* buf, size_t len, size_t& transferred);
|
||||||
EResult recv(void* buf, size_t len);
|
EResult recv(void* buf, size_t len);
|
||||||
|
|
||||||
operator bool() const { return isOpen(); }
|
explicit operator bool() const { return isOpen(); }
|
||||||
|
|
||||||
SocketTp GetInternalSocket() const { return m_socket; }
|
SocketTp GetInternalSocket() const { return m_socket; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -43,8 +43,8 @@ void Listener::listenerProc() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We use blocking I/O since we have a dedicated transfer thread */
|
/* We use blocking I/O since we have a dedicated transfer thread */
|
||||||
net::Socket acceptData = {true};
|
net::Socket acceptData{true};
|
||||||
net::Socket acceptClock = {true};
|
net::Socket acceptClock{true};
|
||||||
std::string hostname;
|
std::string hostname;
|
||||||
while (m_running) {
|
while (m_running) {
|
||||||
if (m_dataServer.accept(acceptData, hostname) == net::Socket::EResult::OK) {
|
if (m_dataServer.accept(acceptData, hostname) == net::Socket::EResult::OK) {
|
||||||
|
|
Loading…
Reference in New Issue