proxygen
folly::AccessSpreader< Atom >::CpuCache Class Reference

Caches the current CPU and refreshes the cache every so often. More...

Public Member Functions

unsigned cpu ()
 

Private Attributes

unsigned cachedCpu_ {0}
 
unsigned cachedCpuUses_ {0}
 

Static Private Attributes

static constexpr unsigned kMaxCachedCpuUses = 32
 

Detailed Description

template<template< typename > class Atom = std::atomic>
class folly::AccessSpreader< Atom >::CpuCache

Caches the current CPU and refreshes the cache every so often.

Definition at line 289 of file CacheLocality.h.

Member Function Documentation

template<template< typename > class Atom = std::atomic>
unsigned folly::AccessSpreader< Atom >::CpuCache::cpu ( )
inline

Definition at line 291 of file CacheLocality.h.

References folly::AccessSpreader< Atom >::getcpuFunc, and UNLIKELY.

291  {
292  if (UNLIKELY(cachedCpuUses_-- == 0)) {
293  unsigned cpu;
294  AccessSpreader::getcpuFunc(&cpu, nullptr, nullptr);
295  cachedCpu_ = cpu % kMaxCpus;
297  }
298  return cachedCpu_;
299  }
static Getcpu::Func getcpuFunc
#define UNLIKELY(x)
Definition: Likely.h:48
static constexpr unsigned kMaxCachedCpuUses

Member Data Documentation

template<template< typename > class Atom = std::atomic>
unsigned folly::AccessSpreader< Atom >::CpuCache::cachedCpu_ {0}
private

Definition at line 304 of file CacheLocality.h.

template<template< typename > class Atom = std::atomic>
unsigned folly::AccessSpreader< Atom >::CpuCache::cachedCpuUses_ {0}
private

Definition at line 305 of file CacheLocality.h.

template<template< typename > class Atom = std::atomic>
constexpr unsigned folly::AccessSpreader< Atom >::CpuCache::kMaxCachedCpuUses = 32
staticprivate

Definition at line 302 of file CacheLocality.h.


The documentation for this class was generated from the following file: