summaryrefslogtreecommitdiff
path: root/core/io/ip.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-05-14 13:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-05-14 16:54:55 +0200
commit0be6d925dc3c6413bce7a3ccb49631b8e4a6e67a (patch)
treea27e497da7104dd0a64f98a04fa3067668735e91 /core/io/ip.cpp
parent710b34b70227becdc652b4ae027fe0ac47409642 (diff)
Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocks
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
Diffstat (limited to 'core/io/ip.cpp')
-rw-r--r--core/io/ip.cpp21
1 files changed, 0 insertions, 21 deletions
diff --git a/core/io/ip.cpp b/core/io/ip.cpp
index 5de7fb7186..642602d0bc 100644
--- a/core/io/ip.cpp
+++ b/core/io/ip.cpp
@@ -39,9 +39,7 @@ VARIANT_ENUM_CAST(IP::ResolverStatus);
/************* RESOLVER ******************/
struct _IP_ResolverPrivate {
-
struct QueueItem {
-
volatile IP::ResolverStatus status;
IP_Address response;
String hostname;
@@ -62,7 +60,6 @@ struct _IP_ResolverPrivate {
QueueItem queue[IP::RESOLVER_MAX_QUERIES];
IP::ResolverID find_empty_id() const {
-
for (int i = 0; i < IP::RESOLVER_MAX_QUERIES; i++) {
if (queue[i].status == IP::RESOLVER_STATUS_NONE)
return i;
@@ -78,9 +75,7 @@ struct _IP_ResolverPrivate {
bool thread_abort;
void resolve_queues() {
-
for (int i = 0; i < IP::RESOLVER_MAX_QUERIES; i++) {
-
if (queue[i].status != IP::RESOLVER_STATUS_WAITING)
continue;
queue[i].response = IP::get_singleton()->resolve_hostname(queue[i].hostname, queue[i].type);
@@ -93,11 +88,9 @@ struct _IP_ResolverPrivate {
}
static void _thread_function(void *self) {
-
_IP_ResolverPrivate *ipr = (_IP_ResolverPrivate *)self;
while (!ipr->thread_abort) {
-
ipr->sem.wait();
MutexLock lock(ipr->mutex);
@@ -113,7 +106,6 @@ struct _IP_ResolverPrivate {
};
IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
-
MutexLock lock(resolver->mutex);
String key = _IP_ResolverPrivate::get_cache_key(p_hostname, p_type);
@@ -128,7 +120,6 @@ IP_Address IP::resolve_hostname(const String &p_hostname, IP::Type p_type) {
}
IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Type p_type) {
-
MutexLock lock(resolver->mutex);
ResolverID id = resolver->find_empty_id();
@@ -157,7 +148,6 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ
}
IP::ResolverStatus IP::get_resolve_item_status(ResolverID p_id) const {
-
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP::RESOLVER_STATUS_NONE);
MutexLock lock(resolver->mutex);
@@ -171,7 +161,6 @@ IP::ResolverStatus IP::get_resolve_item_status(ResolverID p_id) const {
}
IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
-
ERR_FAIL_INDEX_V(p_id, IP::RESOLVER_MAX_QUERIES, IP_Address());
MutexLock lock(resolver->mutex);
@@ -186,7 +175,6 @@ IP_Address IP::get_resolve_item_address(ResolverID p_id) const {
}
void IP::erase_resolve_item(ResolverID p_id) {
-
ERR_FAIL_INDEX(p_id, IP::RESOLVER_MAX_QUERIES);
MutexLock lock(resolver->mutex);
@@ -195,7 +183,6 @@ void IP::erase_resolve_item(ResolverID p_id) {
}
void IP::clear_cache(const String &p_hostname) {
-
MutexLock lock(resolver->mutex);
if (p_hostname.empty()) {
@@ -209,7 +196,6 @@ void IP::clear_cache(const String &p_hostname) {
}
Array IP::_get_local_addresses() const {
-
Array addresses;
List<IP_Address> ip_addresses;
get_local_addresses(&ip_addresses);
@@ -221,7 +207,6 @@ Array IP::_get_local_addresses() const {
}
Array IP::_get_local_interfaces() const {
-
Array results;
Map<String, Interface_Info> interfaces;
get_local_interfaces(&interfaces);
@@ -245,7 +230,6 @@ Array IP::_get_local_interfaces() const {
}
void IP::get_local_addresses(List<IP_Address> *r_addresses) const {
-
Map<String, Interface_Info> interfaces;
get_local_interfaces(&interfaces);
for (Map<String, Interface_Info>::Element *E = interfaces.front(); E; E = E->next()) {
@@ -256,7 +240,6 @@ void IP::get_local_addresses(List<IP_Address> *r_addresses) const {
}
void IP::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("resolve_hostname", "host", "ip_type"), &IP::resolve_hostname, DEFVAL(IP::TYPE_ANY));
ClassDB::bind_method(D_METHOD("resolve_hostname_queue_item", "host", "ip_type"), &IP::resolve_hostname_queue_item, DEFVAL(IP::TYPE_ANY));
ClassDB::bind_method(D_METHOD("get_resolve_item_status", "id"), &IP::get_resolve_item_status);
@@ -283,21 +266,18 @@ void IP::_bind_methods() {
IP *IP::singleton = nullptr;
IP *IP::get_singleton() {
-
return singleton;
}
IP *(*IP::_create)() = nullptr;
IP *IP::create() {
-
ERR_FAIL_COND_V_MSG(singleton, nullptr, "IP singleton already exist.");
ERR_FAIL_COND_V(!_create, nullptr);
return _create();
}
IP::IP() {
-
singleton = this;
resolver = memnew(_IP_ResolverPrivate);
@@ -312,7 +292,6 @@ IP::IP() {
}
IP::~IP() {
-
#ifndef NO_THREADS
if (resolver->thread) {
resolver->thread_abort = true;