qb  2.0.0.0
C++17 Actor Framework
qb Issue Watch Star Fork Follow @isndev
Loading...
Searching...
No Matches

CPU information and utilities. More...

#include <memory>
#include <thread>
Include dependency graph for cpu.h:

Go to the source code of this file.

Classes

class  qb::CPU
 Provides platform-independent access to CPU information. More...

Namespaces

namespace  Internals
 Internal helper functions for CPU information.

Functions

template<typename T, typename TCleaner>
auto qb::resource (T handle, TCleaner cleaner)
 Creates a unique_ptr with a custom deleter for a resource.
template<typename TCleaner>
auto qb::resource (void *handle, TCleaner cleaner)
 Creates a unique_ptr with a custom deleter for a void* resource.
template<typename TCleaner>
auto qb::resource (TCleaner cleaner)
 Creates a unique_ptr with a custom deleter using the deleter itself as a handle.
void qb::spin_loop_pause () noexcept
 Fallback implementation of spin_loop_pause for platforms without CPU pause.

Detailed Description

CPU information and utilities.

This file provides platform-independent access to CPU information such as architecture, core count, and frequency. It also includes utilities for CPU-specific operations like spinlock pauses.

Author
qb - C++ Actor Framework

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Function Documentation

◆ resource() [1/3]

template<typename T, typename TCleaner>
auto qb::resource ( T handle,
TCleaner cleaner )

Creates a unique_ptr with a custom deleter for a resource.

This is a helper function to manage resources in a RAII manner with a custom deleter function.

Template Parameters
TType of the resource
TCleanerType of the cleaner/deleter function
Parameters
handleResource handle
cleanerDeleter function
Returns
unique_ptr wrapping the resource with the custom deleter

◆ resource() [2/3]

template<typename TCleaner>
auto qb::resource ( void * handle,
TCleaner cleaner )

Creates a unique_ptr with a custom deleter for a void* resource.

Specialization for void* resources.

Template Parameters
TCleanerType of the cleaner/deleter function
Parameters
handleResource handle
cleanerDeleter function
Returns
unique_ptr wrapping the resource with the custom deleter

◆ resource() [3/3]

template<typename TCleaner>
auto qb::resource ( TCleaner cleaner)

Creates a unique_ptr with a custom deleter using the deleter itself as a handle.

This variant is useful for self-contained resources.

Template Parameters
TCleanerType of the cleaner/deleter function
Parameters
cleanerDeleter function
Returns
unique_ptr with the deleter pointing to itself

◆ spin_loop_pause()

void qb::spin_loop_pause ( )
inlinenoexcept

Fallback implementation of spin_loop_pause for platforms without CPU pause.

Calls std::this_thread::yield() as a fallback.