Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
thread_pool_start_failure_test.cc File Reference

Tests for a ThreadPool whose worker threads cannot all be started. More...

#include <gtest/gtest.h>
#include <thread_pool.H>
#include <cstddef>
#include <cstdlib>
#include <new>
#include <stdexcept>
#include <thread>
Include dependency graph for thread_pool_start_failure_test.cc:

Go to the source code of this file.

Macros

#define ALEPH_START_FAILURE_TEST_UNDER_TSAN   0
 

Functions

void * operator new (std::size_t size)
 
void * operator new[] (std::size_t size)
 
void * operator new (std::size_t size, const std::nothrow_t &) noexcept
 
void * operator new[] (std::size_t size, const std::nothrow_t &) noexcept
 
void operator delete (void *ptr) noexcept
 
void operator delete[] (void *ptr) noexcept
 
void operator delete (void *ptr, std::size_t) noexcept
 
void operator delete[] (void *ptr, std::size_t) noexcept
 
void operator delete (void *ptr, const std::nothrow_t &) noexcept
 
void operator delete[] (void *ptr, const std::nothrow_t &) noexcept
 
 TEST (ThreadPoolStartFailure, ConstructorStopsTheStartedWorkersAndRethrows)
 
 TEST (ThreadPoolStartFailure, FailedResizeLeavesThePoolStopped)
 

Detailed Description

Tests for a ThreadPool whose worker threads cannot all be started.

The global operator new is replaced so that one allocation of the test thread fails on demand. Starting a std::thread allocates the state of the new thread with it in libstdc++, libc++ and the MSVC STL, so a failed allocation is a worker that cannot be started, without exhausting the resources of the system. The standard does not require that allocation; the tests check it first and are skipped without it.

Definition in file thread_pool_start_failure_test.cc.

Macro Definition Documentation

◆ ALEPH_START_FAILURE_TEST_UNDER_TSAN

#define ALEPH_START_FAILURE_TEST_UNDER_TSAN   0

Definition at line 62 of file thread_pool_start_failure_test.cc.

Function Documentation

◆ operator delete() [1/3]

void operator delete ( void *  ptr)
noexcept

Definition at line 138 of file thread_pool_start_failure_test.cc.

◆ operator delete() [2/3]

void operator delete ( void *  ptr,
const std::nothrow_t &   
)
noexcept

Definition at line 146 of file thread_pool_start_failure_test.cc.

◆ operator delete() [3/3]

void operator delete ( void *  ptr,
std::size_t   
)
noexcept

Definition at line 142 of file thread_pool_start_failure_test.cc.

◆ operator delete[]() [1/3]

void operator delete[] ( void *  ptr)
noexcept

Definition at line 140 of file thread_pool_start_failure_test.cc.

◆ operator delete[]() [2/3]

void operator delete[] ( void *  ptr,
const std::nothrow_t &   
)
noexcept

Definition at line 148 of file thread_pool_start_failure_test.cc.

◆ operator delete[]() [3/3]

void operator delete[] ( void *  ptr,
std::size_t   
)
noexcept

Definition at line 144 of file thread_pool_start_failure_test.cc.

◆ operator new() [1/2]

void * operator new ( std::size_t  size)

Definition at line 110 of file thread_pool_start_failure_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ operator new() [2/2]

void * operator new ( std::size_t  size,
const std::nothrow_t &   
)
noexcept

Definition at line 114 of file thread_pool_start_failure_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ operator new[]() [1/2]

void * operator new[] ( std::size_t  size)

Definition at line 112 of file thread_pool_start_failure_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ operator new[]() [2/2]

void * operator new[] ( std::size_t  size,
const std::nothrow_t &   
)
noexcept

Definition at line 126 of file thread_pool_start_failure_test.cc.

References Aleph::allocate(), and Aleph::size().

◆ TEST() [1/2]

TEST ( ThreadPoolStartFailure  ,
ConstructorStopsTheStartedWorkersAndRethrows   
)

◆ TEST() [2/2]