mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
pow-testgiver support
This commit is contained in:
parent
dbde9c1c40
commit
f064b1047a
257 changed files with 6665 additions and 2608 deletions
|
@ -16,34 +16,34 @@
|
|||
|
||||
Copyright 2017-2020 Telegram Systems LLP
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "td/utils/port/thread.h"
|
||||
#include "td/utils/common.h"
|
||||
#include "td/utils/port/thread_local.h"
|
||||
#include "td/utils/int_types.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
|
||||
namespace td {
|
||||
template <class T>
|
||||
class ThreadLocalStorage {
|
||||
public:
|
||||
T& get() {
|
||||
T &get() {
|
||||
return thread_local_node().value;
|
||||
}
|
||||
|
||||
template <class F>
|
||||
void for_each(F&& f) {
|
||||
int n = max_thread_id_.load();
|
||||
for (int i = 0; i < n; i++) {
|
||||
void for_each(F &&f) {
|
||||
int32 n = max_thread_id_.load();
|
||||
for (int32 i = 0; i < n; i++) {
|
||||
f(nodes_[i].value);
|
||||
}
|
||||
}
|
||||
template <class F>
|
||||
void for_each(F&& f) const {
|
||||
int n = max_thread_id_.load();
|
||||
for (int i = 0; i < n; i++) {
|
||||
void for_each(F &&f) const {
|
||||
int32 n = max_thread_id_.load();
|
||||
for (int32 i = 0; i < n; i++) {
|
||||
f(nodes_[i].value);
|
||||
}
|
||||
}
|
||||
|
@ -51,13 +51,13 @@ class ThreadLocalStorage {
|
|||
private:
|
||||
struct Node {
|
||||
T value{};
|
||||
char padding[128];
|
||||
char padding[TD_CONCURRENCY_PAD];
|
||||
};
|
||||
static constexpr int MAX_THREAD_ID = 128;
|
||||
std::atomic<int> max_thread_id_{MAX_THREAD_ID};
|
||||
static constexpr int32 MAX_THREAD_ID = 128;
|
||||
std::atomic<int32> max_thread_id_{MAX_THREAD_ID};
|
||||
std::array<Node, MAX_THREAD_ID> nodes_;
|
||||
|
||||
Node& thread_local_node() {
|
||||
Node &thread_local_node() {
|
||||
auto thread_id = get_thread_id();
|
||||
CHECK(0 <= thread_id && static_cast<size_t>(thread_id) < nodes_.size());
|
||||
return nodes_[thread_id];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue