Minor fixes.

This commit is contained in:
levlam 2022-07-14 18:38:48 +03:00
parent bf80c43c05
commit abc9ed2cd9
18 changed files with 51 additions and 45 deletions

View File

@ -59,11 +59,11 @@ function(get_git_head_revision _refspecvar _hashvar)
_git_find_closest_git_dir("${CMAKE_CURRENT_SOURCE_DIR}" GIT_DIR)
file(RELATIVE_PATH _relative_to_source_dir "${CMAKE_CURRENT_SOURCE_DIR}" "${GIT_DIR}")
if ("${_relative_to_source_dir}" MATCHES "^[.][.]")
if (_relative_to_source_dir MATCHES "^[.][.]")
# We've gone above the CMake root dir.
set(GIT_DIR "")
endif()
if ("${GIT_DIR}" STREQUAL "")
if (GIT_DIR STREQUAL "")
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
@ -83,7 +83,7 @@ function(get_git_head_revision _refspecvar _hashvar)
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE out
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
if (NOT "${out}" STREQUAL "")
if (NOT out STREQUAL "")
# If out is non-empty, GIT_DIR/CMAKE_CURRENT_SOURCE_DIR is in a submodule
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)$" "\\1" GIT_DIR_RELATIVE ${submodule})

View File

@ -28,7 +28,7 @@ if(HEAD_CONTENTS MATCHES "ref")
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
if (PACKED_REFS MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()

View File

@ -73,7 +73,7 @@ at [tdl](https://github.com/Bannerets/tdl), which provides a convenient, fully-a
You can also see [TdNode](https://github.com/puppy0cam/TdNode), [tglib](https://github.com/nodegin/tglib), [node-tdlib](https://github.com/wfjsw/node-tdlib), [tdlnode](https://github.com/fonbah/tdlnode),
[Paper Plane](https://github.com/par6n/paper-plane), or [node-tlg](https://github.com/dilongfa/node-tlg) for other examples of TDLib JSON interface integration with Node.js.
See also the source code of [DIBgram](https://github.com/DIBgram/DIBgram) - an unofficial Telegram web app which looks like Telegram Desktop.
See also the source code of [DIBgram](https://github.com/DIBgram/DIBgram) - an unofficial Telegram web application which looks like Telegram Desktop.
TDLib can be used also from NativeScript through the [JSON](https://github.com/tdlib/td#using-json) interface.
See [nativescript-tglib](https://github.com/arpit2438735/nativescript-tglib) as an example of a NativeScript library for building Telegram clients.

View File

@ -25,7 +25,6 @@
#include "td/utils/logging.h"
#include "td/utils/misc.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/Slice.h"
#include "td/utils/SliceBuilder.h"
@ -195,7 +194,7 @@ Status NetQueryDispatcher::wait_dc_init(DcId dc_id, bool force) {
return Status::Error("Closing");
}
#if !TD_THREAD_UNSUPPORTED
td::usleep_for(1);
usleep_for(1);
#endif
}
}
@ -332,7 +331,7 @@ void NetQueryDispatcher::set_main_dc_id(int32 new_main_dc_id) {
return;
}
// Very rare event. Mutex is ok.
// Very rare event; mutex is ok.
std::lock_guard<std::mutex> guard(main_dc_id_mutex_);
if (new_main_dc_id == main_dc_id_) {
return;

View File

@ -8,6 +8,8 @@
#include "td/actor/actor.h"
#include "td/utils/common.h"
namespace td {
class Timeout final : public Actor {

View File

@ -11,6 +11,7 @@
#include "td/actor/impl/EventFull-decl.h"
#include "td/utils/Closure.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashMap.h"
#include "td/utils/Heap.h"
#include "td/utils/List.h"

View File

@ -21,6 +21,7 @@
#include "td/utils/MpscPollableQueue.h"
#include "td/utils/ObjectPool.h"
#include "td/utils/port/thread_local.h"
#include "td/utils/Promise.h"
#include "td/utils/ScopeGuard.h"
#include "td/utils/Time.h"

View File

@ -8,7 +8,6 @@
#include "td/utils/common.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/type_traits.h"
#include <atomic>
@ -21,11 +20,11 @@ template <class T>
class AtomicRead {
public:
void read(T &dest) const {
int it = 0;
const int wait_each_it = 4;
auto wait = [&]() {
it++;
if (it % wait_each_it == 0) {
uint32 counter = 0;
auto wait = [&] {
counter++;
const int wait_each_count = 4;
if (counter % wait_each_count == 0) {
usleep_for(1);
}
};

View File

@ -15,7 +15,6 @@
#include "td/utils/HazardPointers.h"
#include "td/utils/logging.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/ScopeGuard.h"
#include <array>
@ -306,7 +305,7 @@ class MpmcQueueOld {
if (try_pop(value, thread_id)) {
return value;
}
td::usleep_for(1);
usleep_for(1);
}
}
@ -430,7 +429,7 @@ class MpmcQueue {
if (try_pop(value, thread_id)) {
return value;
}
td::usleep_for(1);
usleep_for(1);
}
}

View File

@ -9,7 +9,6 @@
#include "td/utils/common.h"
#include "td/utils/logging.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include <algorithm>
#include <atomic>

View File

@ -7,7 +7,6 @@
#pragma once
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include <atomic>
#include <memory>

View File

@ -1,8 +1,15 @@
//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include <mutex>
namespace td {
class Mutex {
public:
struct Guard {
@ -19,4 +26,5 @@ class Mutex {
private:
std::mutex mutex_;
};
} // namespace td

View File

@ -7,7 +7,7 @@
#pragma once
#include "td/utils/port/EventFd.h"
#include "td/utils/port/thread.h"
#include "td/utils/port/sleep.h"
#if !TD_THREAD_UNSUPPORTED && !TD_EVENTFD_UNSUPPORTED
@ -32,7 +32,7 @@ class Backoff {
if (cnt < 1) { // 50
return true;
} else {
td::usleep_for(1);
usleep_for(1);
return cnt < 3; // 500
}
}
@ -47,7 +47,7 @@ class InfBackoff {
if (cnt < 50) {
return true;
} else {
td::usleep_for(1);
usleep_for(1);
return true;
}
}

View File

@ -11,11 +11,11 @@
#include "td/utils/format.h"
#include "td/utils/logging.h"
#include "td/utils/port/sleep.h"
#include "td/utils/port/thread.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
#include <atomic>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <utility>

View File

@ -13,7 +13,6 @@
#include "td/utils/tests.h"
#include <atomic>
#include <mutex>
#if !TD_THREAD_UNSUPPORTED