2
3
4
5
8#include <gmock/gmock.h>
9#include <Core/Thread/ThreadPoolBasic.h>
15
16
17
23
24
25
27 m_ThreadPool.SetMode(Spices::PoolMode::MODE_CACHED);
28 m_ThreadPool.SetThreadIdleTimeOut(10);
29 m_ThreadPool.Start(nThreads);
37
38
42
43
48
49
54 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
55 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
56 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
57 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
58 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
59 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
60 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
64
65
70 auto func = [](
int sec) ->
bool
72 std::this_thread::sleep_for(std::chrono::seconds(sec));
76 std::future<
bool> future = m_ThreadPool.SubmitPoolTask(std::bind(func, 2));
80 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
81 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads - 1 );
82 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
83 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
84 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
85 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
86 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
90 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
91 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
92 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
93 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
94 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
95 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
96 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
100
101
106 auto func = [](
int sec) ->
bool
108 std::this_thread::sleep_for(std::chrono::seconds(sec));
112 std::vector<std::future<
bool>> futures(nThreads);
113 for (
int i = 0; i < nThreads; i++)
115 futures[i] = m_ThreadPool.SubmitPoolTask(std::bind(func, 2));
120 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
121 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,0 );
122 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
123 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
124 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
125 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
126 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
129 for (
int i = 0; i < nThreads; i++)
134 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
135 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
136 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
137 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
138 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
139 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
140 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
144
145
150 auto func = [](
int sec) ->
bool
152 std::this_thread::sleep_for(std::chrono::seconds(sec));
156 std::vector<std::future<
bool>> futures(2 * nThreads);
157 for (
int i = 0; i < 2 * nThreads; i++)
159 futures[i] = m_ThreadPool.SubmitPoolTask(std::bind(func, 2));
164 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
165 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,0 );
166 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
167 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
168 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,2 * nThreads );
169 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
170 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
173 for (
int i = 0; i < 2 * nThreads; i++)
178 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
179 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,2 * nThreads );
180 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
181 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
182 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,2 * nThreads );
183 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
184 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
189 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
190 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
191 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
192 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
193 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
194 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
195 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
199
200
205 auto func = [](
int sec) ->
bool
207 std::this_thread::sleep_for(std::chrono::microseconds(sec));
211 std::vector<std::future<
bool>> futures(10000);
212 for (
int i = 0; i < 10000; i++)
214 futures[i] = m_ThreadPool.SubmitPoolTask(std::bind(func, 1));
219 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,Spices::THREAD_MAX_THRESHHOLD);
222 for (
int i = 0; i < 10000; i++)
227 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
228 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,Spices::THREAD_MAX_THRESHHOLD);
229 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
230 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
231 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,Spices::THREAD_MAX_THRESHHOLD);
232 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
233 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
236 auto inTime = std::chrono::high_resolution_clock::now();
237 while (m_ThreadPool.GetThreadsCount() != nThreads)
241 auto outTime = std::chrono::high_resolution_clock::now();
243 std::cout <<
"Cache Mode recovery threads cost: " << std::chrono::duration_cast<std::chrono::milliseconds>(outTime - inTime).count() << std::endl;
245 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
246 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
247 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
248 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
249 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
250 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
251 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
255
256
261 auto func = []() ->
void
263 std::this_thread::sleep_for(std::chrono::seconds(2));
266 m_ThreadPool.SubmitThreadTask_LightWeight(0, func);
271 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
272 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
273 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
274 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
275 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
276 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
277 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
279 for (
auto& pair : m_ThreadPool.GetThreads())
281 EXPECT_EQ(pair.second->GetThreadTasksCount(), 0);
286
287
292 auto func = []() ->
void
294 std::this_thread::sleep_for(std::chrono::seconds(2));
297 m_ThreadPool.SubmitThreadTask_LightWeight_ForEach(func);
302 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
303 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
304 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
305 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
306 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
307 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
308 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
310 for (
auto& pair : m_ThreadPool.GetThreads())
312 EXPECT_EQ(pair.second->GetThreadTasksCount(), 0);
317
318
323 auto func = []() ->
void
325 std::this_thread::sleep_for(std::chrono::seconds(1));
328 m_ThreadPool.SubmitThreadTask_LightWeight_ForEach(func);
329 m_ThreadPool.SubmitThreadTask_LightWeight_ForEach(func);
334 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
335 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
336 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
337 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
338 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
339 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
340 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
342 for (
auto& pair : m_ThreadPool.GetThreads())
344 EXPECT_EQ(pair.second->GetThreadTasksCount(), 0);
349
350
355 auto func = []() ->
void
357 std::this_thread::sleep_for(std::chrono::microseconds(1));
360 for (
int i = 0; i < 2000; i++)
362 m_ThreadPool.SubmitThreadTask_LightWeight_ForEach(func);
368 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
369 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
370 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
371 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
372 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
373 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
374 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
376 for (
auto& pair : m_ThreadPool.GetThreads())
378 EXPECT_EQ(pair.second->GetThreadTasksCount(), 0);
383
384
389 auto func = []() ->
void
391 std::this_thread::sleep_for(std::chrono::microseconds(1));
393 auto func1 = [](
int sec) ->
void
395 std::this_thread::sleep_for(std::chrono::microseconds(sec));
398 for (
int i = 0; i < 5000; i++)
400 m_ThreadPool.SubmitPoolTask(func);
403 for (
int i = 0; i < 1000; i++)
405 m_ThreadPool.SubmitThreadTask_LightWeight_ForEach(func);
411 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
412 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,Spices::THREAD_MAX_THRESHHOLD);
413 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
414 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
415 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,Spices::THREAD_MAX_THRESHHOLD);
416 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
417 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
419 for (
auto& pair : m_ThreadPool.GetThreads())
421 EXPECT_EQ(pair.second->GetThreadTasksCount(), 0);
425 while (m_ThreadPool.GetThreadsCount() != nThreads)
430 EXPECT_EQ(m_ThreadPool.GetInitThreadSize() ,nThreads );
431 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize() ,nThreads );
432 EXPECT_EQ(m_ThreadPool.GetPoolMode() ,Spices::PoolMode::MODE_CACHED);
433 EXPECT_EQ(m_ThreadPool.GetTasks() ,0 );
434 EXPECT_EQ(m_ThreadPool.GetThreadsCount() ,nThreads );
435 EXPECT_EQ(m_ThreadPool.GetThreadIdleTimeOut(),10 );
436 EXPECT_EQ(m_ThreadPool.IsPoolRunning() ,
true );
440
441
446 m_ThreadPool.Suspend();
448 std::atomic_int executeCount;
453 for (
int i = 0; i < 10; i++)
455 m_ThreadPool.SubmitPoolTask([&]() {
460 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize(), 10);
461 EXPECT_EQ(m_ThreadPool.GetTasks(), 10);
463 m_ThreadPool.Continue();
466 m_ThreadPool.Suspend();
468 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize(), 10);
469 EXPECT_EQ(m_ThreadPool.GetTasks(), 0);
470 EXPECT_EQ(executeCount.load(), 10);
476 for (
int i = 0; i < 10; i++)
478 m_ThreadPool.SubmitPoolTask([&]() {
479 std::this_thread::sleep_for(std::chrono::seconds(2));
484 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize(), 10);
485 EXPECT_EQ(m_ThreadPool.GetTasks(), 10);
487 m_ThreadPool.Continue();
488 std::this_thread::sleep_for(std::chrono::seconds(1));
489 m_ThreadPool.Suspend();
490 std::this_thread::sleep_for(std::chrono::seconds(2));
492 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize(), 10);
493 EXPECT_EQ(m_ThreadPool.GetTasks(), 0);
494 EXPECT_EQ(executeCount.load(), 20);
496 m_ThreadPool.Continue();
499 EXPECT_EQ(m_ThreadPool.GetIdleThreadSize(), 10);
500 EXPECT_EQ(m_ThreadPool.GetTasks(), 0);
501 EXPECT_EQ(executeCount.load(), 20);
#define UFUNCTION_T(T, N)
#define UDECONSTRUCT(T, N)
#define DELEGATE_ONE_PARAM(name, p0)
Use this macro to instance a Delegate Class. One Parameter Specific.
#define DELEGATE_THREE_PARAM(name, p0, p1, p2)
Use this macro to instance a Delegate Class. Three Parameter Specific.
#define DELEGATE_SIX_PARAM(name, p0, p1, p2, p3, p4, p5)
Use this macro to instance a Delegate Class. Six Parameter Specific.
#define DELEGATE_FIVE_PARAM(name, p0, p1, p2, p3, p4)
Use this macro to instance a Delegate Class. Five Parameter Specific.
#define DELEGATE_NONE_PARAM(name)
Use this macro to instance a Delegate Class. None Parameter Specific.
#define DELEGATE_SEVEN_PARAM(name, p0, p1, p2, p3, p4, p5, p6)
Use this macro to instance a Delegate Class. Seven Parameter Specific.
#define DELEGATE_EIGHT_PARAM(name, p0, p1, p2, p3, p4, p5, p6, p7)
Use this macro to instance a Delegate Class. Eight Parameter Specific.
#define DELEGATE_TWO_PARAM(name, p0, p1)
Use this macro to instance a Delegate Class. Two Parameter Specific.
#define DELEGATE_FOUR_PARAM(name, p0, p1, p2, p3)
Use this macro to instance a Delegate Class. Four Parameter Specific.
#define DELEGATE_NINE_PARAM(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)
Use this macro to instance a Delegate Class. Nine Parameter Specific.
#define SPICESTEST_PROFILE_SCOPE_LINE2(name, line)
#define SPICESTEST_PROFILE_SCOPE(name)
#define SPICESTEST_PROFILE_END_SESSION()
#define SPICESTEST_PROFILE_BEGIN_SESSION(name, filepath)
#define SPICESTEST_PROFILE_SCOPE_LINE(name, line)
#define SPICESTEST_PROFILE_FUNCTION()
#define SPICES_PROFILE_ZONE
void Test0(int a, int b)
Basic Class Function.
void Test(float f)
Basic Override Class Function.
void Test()
Basic Override Class Function.
static void Test1()
Static Class Function.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
Testing class TearDown function.
bool b(int q, float w) const
static std::string m_Name_c
static bool c(int q, float w)
const volatile std::string m_Name_b
FieldTraitsTest(const std::string &name)
~FieldTraitsTest()=default
static bool sf(int a, float b, void *c)
int f(int a, float b, void *c)
bool fc(int a, float b, void *c) const
auto GetFResult(T &&func, Args &&... args) -> decltype(func(std::forward< Args >(args)...))
InstrumentationTimer(const char *name)
std::chrono::time_point< std::chrono::steady_clock > m_StartTimepoint
Instrumentor(Instrumentor &&)=delete
static Instrumentor & Get()
void BeginSession(const std::string &name, const std::string &filepath="results.json")
void WriteProfile(const ProfileResult &result)
InstrumentationSession * m_CurrentSession
std::ofstream m_OutputStream
Instrumentor(const Instrumentor &)=delete
void InternalEndSession()
MemoryPoolTest2(const MemoryPoolTest2 &)=delete
MemoryPoolTest2 & operator=(const MemoryPoolTest2 &)=delete
MemoryPoolTest2()=default
static constexpr size_t y
std::array< std::array< int, x >, y > datas
static constexpr size_t x
MemoryPoolTest(const MemoryPoolTest &)=delete
MemoryPoolTest & operator=(const MemoryPoolTest &)=delete
std::tuple< int, float, void * > m_Tuple
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
static constexpr size_t n2
Iter counts 2.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
static constexpr size_t n
Iter counts.
The interface is inherited from testing::Test. Registry on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
std::unique_ptr< Spices::ObjectPool< Object > > m_ObjectPool
ObjectPool.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
static constexpr size_t n
ObjectPool objects number.
The interface is inherited from testing::Test. Registry on Initialize.
virtual ~Object()=default
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
Spices::PageCache pc
PageCache.
static constexpr size_t n
Test iter number.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
The interface is inherited from testing::Test. Registry on Initialize.
ThreadCacheTest & operator=(const ThreadCacheTest &)=delete
std::tuple< int, float, void * > m_Tuple
ThreadCacheTest(const ThreadCacheTest &)=delete
static constexpr size_t n
Iter counts.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
Spices::ThreadCache tc
ThreadCache.
The interface is inherited from testing::Test. Registry on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
Spices::ThreadPool m_ThreadPool
ThreadPool.
const int nThreads
Number of Threads in ThreadPool.
The interface is inherited from testing::Test. Registry on Initialize.
int nThreads
Number of Threads in ThreadPool.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
Spices::ThreadPool m_ThreadPool
ThreadPool.
The interface is inherited from testing::Test. Registy on Initialize.
std::string Test(std::string str)
Basic Override Class Function.
static bool Test1()
Static Class Function.
int Test0(int a, int b)
Basic Class Function.
bool Test()
Basic Override Class Function.
void Test(float f)
Basic Override Class Function.
static void Test1()
Static Class Function.
void Test()
Basic Override Class Function.
void TearDown() override
Testing class TearDown function.
std::vector< scl::directed_acyclic_node > m_Nodes
void SetUp() override
Testing class initialize function.
scl::directed_acyclic_graph m_DAG
The interface is inherited from testing::Test. Registy on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
scl::free_list m_FreeList
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
The interface is inherited from testing::Test. Registry on Initialize.
scl::kd_tree< 2 > m_KDTree
Create a KDTree with 2 dimensions.
void TearDown() override
Testing class TearDown function.
void SetUp() override
Testing class initialize function.
The interface is inherited from testing::Test. Registry on Initialize.
scl::linked_unordered_map< int, std::string > c1
scl::linked_unordered_map< float, std::string > c2
scl::linked_unordered_map< std::string, std::string > c0
void SetUp() override
Testing class initialize function.
void TearDown() override
Testing class TearDown function.
The interface is inherited from testing::Test. Registry on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
Testing class TearDown function.
scl::runtime_memory_block m0
Unit Test for RuntimeMemoryBlock.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
scl::span_list m_SpanList
The interface is inherited from testing::Test. Registry on Initialize.
static std::string GetClassString(ClassType t)
Get Class Name as string.
Class Static Function Library.
virtual ~ClassTraitsTest()=default
bool f(int q, float w, void *c, bool(ClassTraitsTest::*)(int **, int &&))
std::reference_wrapper< const int > cir
std::reference_wrapper< int * > ipr
std::reference_wrapper< const int * > cipr
std::reference_wrapper< const int const *const > cicpcr
bool fc(int q, float w) const
static bool fs(int q, float w)
auto mfc(F func, Args ...args) -> decltype(f(std::forward< Args >(args)...))
std::reference_wrapper< int > ir
static bool FileLibrary_Size(const FileHandle *handle, uint64_t *out_size)
Calculate The file size.
static bool FileLibrary_Read(const FileHandle *handle, uint64_t data_size, void *out_data, uint64_t *out_bytes_read)
Read Specific size of data form the current file handle pointer, and move pointer the same size.
static bool FileLibrary_Write_Line(const FileHandle *handle, const char *text)
Write one line data to the file handle pointer.
static bool FileLibrary_Write(const FileHandle *handle, uint64_t data_size, const void *data, uint64_t *out_bytes_written)
Write given data to the file handle pointer.
static bool FileLibrary_Open(const char *path, FileModes mode, bool binary, FileHandle *out_handle)
Open the file using given string.
static void FileLibrary_Close(FileHandle *handle)
Close the file by the file handle.
static bool FileLibrary_Delete(const char *filePath)
Delete a file from disk.
static bool FileLibrary_CopyFile(std::string srcFilePath, std::string dstFilePath)
Copy a file to dst path.
static bool FileLibrary_Read_Line(const FileHandle *handle, uint64_t max_length, char *line_buf, uint64_t *out_line_length)
Read one line from the current file handle pointer, and move pointer the same size.
static bool FileLibrary_Exists(const char *path)
Determine whether the given string is existing a file.
static bool FileLibrary_Read_all_bytes(const FileHandle *handle, char *out_bytes, uint64_t *out_bytes_read)
Read all data form the current file handle pointer.
File Static Function Library.
static void Init()
Init Log.
static void ShutDown()
Shutdown Log.
static void Free(void *ptr)
Free memory entry point.
static void *& PointerSpace(void *obj)
Get object first 4/8 bytes as a pointer.
Page memory cache. Third level of memory allocator.
static bool CloseProcess(const char *processName)
Close a Process with command.
static bool OpenProcess(const char *processPath, const char *commandLine="")
Open a Process with command.
static float ProcessMemoryInUsed()
Get this Process Memory used( GB ).
Process Static Function Library.
static bool StringsEqual(const char *str0, const char *str1)
Determine if the strings given are equal. Platform Specific.
String Static Function Library.
Thread memory cache. First level of memory allocator.
static bool SetThreadName(const std::string &name)
Set Thread name.
Thread Static Function Library.
behave_state_list. wrapper of combing all state behaves.
bool Empty() const
Determine if this list is empty.
void Push(void *obj)
Recycle a object memory to this free list.
void *& Begin()
Get current pointer (no const & reference version).
void *& End()
Get end pointer (no const & reference version).
Free list for memory pool.
The kd_tree with K dimensions container Class. K the number of dimensions. Every node in the tree is ...
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
void build()
Malloc a memory to begin_.
void add_element(const std::string &name, const std::string &type)
Add a element to object_, means a memory block will be occupied with given param type.
runtime_memory_block()=default
Constructor Function.
void * get_addr() const
Get the begin_.
The container is wrapper of a continue memory block. Used in Material::BuildMaterial(),...
Bidirectional cyclic linked list for span.
span * m_Prev
previous span.
Used for manage multiple page memory.
This Class is similar to std::vector, the difference between that is this one allocates memory by mal...
int main(int argc, char **argv)
The Entry of SpicesTest.
static bool sf(int a, float b, void *c)
constexpr auto CleanupOutputString(const char(&expr)[N], const char(&remove)[K])
TEST_F(free_list_test, PushPop)
Testing scl::free_list::Push/Pop.
TEST_F(runtime_memory_block_test, Initialize)
Testing if initialize successfully.
TEST_F(directed_acyclic_graph_test, Addnode)
Testing if add node successfully.
TEST_F(ThreadPoolFixed_test, Initialize)
Testing if initialize successfully.
TEST_F(span_list_test, Initialize)
Testing scl::span_list::Initialize.
TEST_F(linked_unordered_map_test, Initialize)
Testing if initialize successfully.
TEST_F(kd_tree_test, Insert)
Testing if Insert successfully.
void DelegateTestT(Args ...args)
Template Function.
TEST_F(MemoryPool_test, PointerSpace)
Testing Spices::MemoryPool::PointerSpace.
TEST(tuple_test, IterTuple)
Testing std::tuple Helper Function.
RType ThreadPoolTestT(Args &&...args)
Template Function.
TEST_F(ObjectPool_test, Initialize)
Testing Spices::ObjectPool::Initialize.
TEST_F(Delegate_test, Bind)
Testing if bind successfully.
TEST_F(ThreadPoolCached_test, Initialize)
Testing if initialize successfully.
TEST_F(ThreadCache_test, AllocateDeallocate)
Testing Spices::ThreadCache::Allocate/Deallocate.
TEST_F(PageCache_test, NewSpan)
Testing Spices::PageCache::NewSpan.
constexpr bool is_pointer_v< _Ty *const volatile >
Spices::ClassTraitsTest inst
constexpr bool is_pointer_v< _Ty *const >
constexpr bool is_const_v
value of is_const.
ClassItemType
class property/function type.
constexpr bool is_pointer_v< _Ty * >
constexpr bool is_pointer_v< _Ty *volatile >
@ FILE_MODE_READ
model : read
@ FILE_MODE_WRITE
model : write
constexpr bool is_pointer_v
Declare of is_pointer.
void IterTuple(Tuple &tuple, Function &&f)
Iter a tuple.
std::chrono::microseconds ElapsedTime
FloatingPointMicroseconds Start
static constexpr bool value
static constexpr bool value
void * handle
FILE* handle. Need cast while use.
bool is_valid
Is this handle Valid.
This Struct is FILE* handle pointer Wrapper.
bool operator==(const String2 &other) const
equal operation.
bool operator==(const UInt2 &other) const
equal operation.
UInt2(const uint32_t &x, const uint32_t &y)
Constructor Function.
constexpr bool is_const() const
constexpr bool is_variable() const
constexpr bool is_function() const
constexpr bool is_member() const
constexpr bool is_variable() const
constexpr bool is_member() const
constexpr bool is_function() const
constexpr bool is_const() const
constexpr size_t param_count() const
static constexpr bool value
is_const remove pointer from type.
static constexpr bool value
is_const remove reference(both pointer) from type. For reference and pointer can be mixed together.
static constexpr bool value
static constexpr bool value
static constexpr bool value
Store Non Member Variable Type.
std::string_view name
Field Name.
size_t offset
Field offset.
constexpr field_traits(T &&p, std::string_view n, size_t offset=0)
static constexpr bool is_const
static constexpr bool is_member
Collection of Type and Class.
is_const process pointer or reference.
Container of store Types.