Skip to content

Commit 3695004

Browse files
committed
Moved some things around to clean up ::react namespace.
1 parent 8d9e9b6 commit 3695004

22 files changed

Lines changed: 114 additions & 133 deletions

include/react/ReactiveObject.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class ReactiveObject
108108
#define REACTIVE_REF(obj, name) \
109109
Flatten( \
110110
MakeSignal( \
111-
[] (Identity<decltype(obj)>::Type::ValueT::type& r) \
111+
[] (REACT_IMPL::Identity<decltype(obj)>::Type::ValueT::type& r) \
112112
{ \
113113
return r.name; \
114114
}, \
@@ -117,7 +117,7 @@ class ReactiveObject
117117
#define REACTIVE_PTR(obj, name) \
118118
Flatten( \
119119
MakeSignal( \
120-
[] (Identity<decltype(obj)>::Type::ValueT r) \
120+
[] (REACT_IMPL::Identity<decltype(obj)>::Type::ValueT r) \
121121
{ \
122122
REACT_ASSERT(r != nullptr); \
123123
return r->name; \

include/react/common/Concurrency.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <mutex>
1212
#include <condition_variable>
1313

14-
/***********************************/ REACT_BEGIN /************************************/
14+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1515

1616
class BlockingCondition
1717
{
@@ -78,4 +78,25 @@ class BlockingCondition
7878
bool blocked_ = false;
7979
};
8080

81-
/************************************/ REACT_END /*************************************/
81+
////////////////////////////////////////////////////////////////////////////////////////
82+
/// ThreadLocalPtr
83+
////////////////////////////////////////////////////////////////////////////////////////
84+
template <typename T>
85+
class ThreadLocalStaticPtr
86+
{
87+
public:
88+
static T* Get() { return ptr_; }
89+
static void Set(T* ptr) { ptr_ = ptr; }
90+
static void Reset() { ptr_ = nullptr; }
91+
static bool IsNull() { return ptr_ == nullptr; }
92+
93+
private:
94+
ThreadLocalStaticPtr() {}
95+
96+
static __declspec(thread) T* ptr_;
97+
};
98+
99+
template <typename T>
100+
T* ThreadLocalStaticPtr<T>::ptr_(nullptr);
101+
102+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/Containers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <array>
1313
#include <vector>
1414

15-
/***********************************/ REACT_BEGIN /************************************/
15+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1616

1717
////////////////////////////////////////////////////////////////////////////////////////
1818
/// NodeVector
@@ -87,4 +87,4 @@ class NodePtrBuffer
8787
DataT nodes_;
8888
};
8989

90-
/************************************/ REACT_END /*************************************/
90+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/GraphData.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515
#include "Types.h"
1616

17-
////////////////////////////////////////////////////////////////////////////////////////
18-
namespace react {
17+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1918

2019
////////////////////////////////////////////////////////////////////////////////////////
2120
/// GraphData
@@ -447,5 +446,4 @@ class GraphData
447446

448447
};
449448

450-
// ---
451-
}
449+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/Singleton.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66

77
#pragma once
88

9-
////////////////////////////////////////////////////////////////////////////////////////
10-
namespace react {
9+
#include "react/Defs.h"
10+
11+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1112

1213
////////////////////////////////////////////////////////////////////////////////////////
1314
/// BasicSingleton
@@ -28,4 +29,4 @@ class BasicSingleton
2829
BasicSingleton(BasicSingleton&& other) {}
2930
};
3031

31-
} //~namespace react
32+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/SourceIdSet.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "tbb/queuing_mutex.h"
1515

16-
/***********************************/ REACT_BEGIN /************************************/
16+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1717

1818
////////////////////////////////////////////////////////////////////////////////////////
1919
/// SourceIdSet
@@ -127,4 +127,4 @@ class SourceIdSet
127127
}
128128
};
129129

130-
/************************************/ REACT_END /*************************************/
130+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/TopoQueue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <array>
1313
#include <vector>
1414

15-
/***********************************/ REACT_BEGIN /************************************/
15+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1616

1717
////////////////////////////////////////////////////////////////////////////////////////
1818
/// TopoQueue
@@ -57,4 +57,4 @@ class TopoQueue
5757
std::vector<T*> data_;
5858
};
5959

60-
/************************************/ REACT_END /*************************************/
60+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/Types.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "react/Defs.h"
1010
#include <cstdint>
1111

12-
/***********************************/ REACT_BEGIN /************************************/
12+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
1313

1414
using ObjectId = uintptr_t;
1515

@@ -22,4 +22,4 @@ ObjectId GetObjectId(const O& obj)
2222
using TurnIdT = uint;
2323
using TurnFlagsT = uint;
2424

25-
/************************************/ REACT_END /*************************************/
25+
/**********************************/ REACT_IMPL_END /**********************************/

include/react/common/Util.h

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,7 @@
1818
#include <type_traits>
1919
#include <utility>
2020

21-
/***********************************/ REACT_BEGIN /************************************/
22-
23-
////////////////////////////////////////////////////////////////////////////////////////
24-
/// ThreadLocalPtr
25-
////////////////////////////////////////////////////////////////////////////////////////
26-
template <typename T>
27-
class ThreadLocalStaticPtr
28-
{
29-
public:
30-
static T* Get() { return ptr_; }
31-
static void Set(T* ptr) { ptr_ = ptr; }
32-
static void Reset() { ptr_ = nullptr; }
33-
static bool IsNull() { return ptr_ == nullptr; }
34-
35-
private:
36-
ThreadLocalStaticPtr() {}
37-
38-
static __declspec(thread) T* ptr_;
39-
};
40-
41-
template <typename T>
42-
T* ThreadLocalStaticPtr<T>::ptr_(nullptr);
21+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
4322

4423
////////////////////////////////////////////////////////////////////////////////////////
4524
/// Unpack tuple - see
@@ -83,45 +62,11 @@ inline auto apply(F && f, T && t)
8362
template <typename... TArgs>
8463
inline void pass(TArgs&& ...) {}
8564

86-
// Expand args by wrapping them in a dummy function
87-
// Use comma operator to replace potential void return value with 0
88-
#define REACT_EXPAND_PACK(...) pass((__VA_ARGS__ , 0) ...)
89-
9065
////////////////////////////////////////////////////////////////////////////////////////
9166
/// Format print bits
9267
////////////////////////////////////////////////////////////////////////////////////////
9368
void PrintBits(size_t const size, void const* const p);
9469

95-
////////////////////////////////////////////////////////////////////////////////////////
96-
// Get current date/time
97-
////////////////////////////////////////////////////////////////////////////////////////
98-
const std::string CurrentDateTime();
99-
100-
////////////////////////////////////////////////////////////////////////////////////////
101-
// Get unique random numbers from range.
102-
////////////////////////////////////////////////////////////////////////////////////////
103-
template <typename T, typename TGen>
104-
const std::vector<T> GetUniqueRandomNumbers(TGen gen, T from, T to, int count)
105-
{
106-
std::vector<T> data(1 + to - from);
107-
int c = from;
108-
for (auto& p : data)
109-
p = c++;
110-
111-
for (int i=0; i<count; i++)
112-
{
113-
std::uniform_int_distribution<T> dist(i,(to - from));
114-
auto r = dist(gen);
115-
116-
if (r != i)
117-
std::swap(data[i], data[r]);
118-
}
119-
data.resize(count);
120-
std::sort(data.begin(), data.end());
121-
122-
return std::move(data);
123-
}
124-
12570
////////////////////////////////////////////////////////////////////////////////////////
12671
// Identity (workaround to enable enable decltype()::X)
12772
////////////////////////////////////////////////////////////////////////////////////////
@@ -131,4 +76,8 @@ struct Identity
13176
using Type = T;
13277
};
13378

134-
/************************************/ REACT_END /*************************************/
79+
/**********************************/ REACT_IMPL_END /**********************************/
80+
81+
// Expand args by wrapping them in a dummy function
82+
// Use comma operator to replace potential void return value with 0
83+
#define REACT_EXPAND_PACK(...) REACT_IMPL::pass((__VA_ARGS__ , 0) ...)

include/react/logging/EventLog.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
#include "tbb/concurrent_vector.h"
2323

24-
/***********************************/ REACT_BEGIN /************************************/
24+
/*********************************/ REACT_IMPL_BEGIN /*********************************/
2525

2626
////////////////////////////////////////////////////////////////////////////////////////
2727
/// EventLog
@@ -94,4 +94,10 @@ class EventLog
9494
Timestamp startTime_;
9595
};
9696

97+
/**********************************/ REACT_IMPL_END /**********************************/
98+
99+
/***********************************/ REACT_BEGIN /************************************/
100+
101+
using EventLog = REACT_IMPL::EventLog;
102+
97103
/************************************/ REACT_END /*************************************/

0 commit comments

Comments
 (0)