Classes | Macros | Functions | Variables
timer_generic.cc File Reference
#include <grpc/support/port_platform.h>
#include <inttypes.h>
#include <string>
#include "absl/strings/str_cat.h"
#include <grpc/support/alloc.h>
#include <grpc/support/cpu.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gpr/spinlock.h"
#include "src/core/lib/gpr/tls.h"
#include "src/core/lib/gpr/useful.h"
#include "src/core/lib/gprpp/time.h"
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/iomgr/port.h"
#include "src/core/lib/iomgr/time_averaged_stats.h"
#include "src/core/lib/iomgr/timer.h"
#include "src/core/lib/iomgr/timer_heap.h"
Include dependency graph for timer_generic.cc:

Go to the source code of this file.

Classes

struct  shared_mutables
 
struct  timer_shard
 

Macros

#define ADD_DEADLINE_SCALE   0.33
 
#define ADD_TO_HASH_TABLE(t)   add_to_ht((t))
 
#define DESTROY_TIMER_HASH_TABLE()   destroy_timer_ht()
 
#define INIT_TIMER_HASH_TABLE()   init_timer_ht()
 
#define INVALID_HEAP_INDEX   0xffffffffu
 
#define MAX_QUEUE_WINDOW_DURATION   1.0
 
#define MIN_QUEUE_WINDOW_DURATION   0.01
 
#define NUM_HASH_BUCKETS   1009 /* Prime number close to 1000 */
 
#define REMOVE_FROM_HASH_TABLE(t)   remove_from_ht((t))
 
#define VALIDATE_NON_PENDING_TIMER(t)   validate_non_pending_timer((t))
 

Functions

static void add_to_ht (grpc_timer *t)
 
static grpc_core::Timestamp compute_min_deadline (timer_shard *shard)
 
static void destroy_timer_ht ()
 
struct shared_mutables GPR_ALIGN_STRUCT (GPR_CACHELINE_SIZE)
 
static GPR_THREAD_LOCAL (int64_t) g_last_seen_min_timer
 
void grpc_timer_init_unset (grpc_timer *timer)
 
static void init_timer_ht ()
 
static bool is_in_ht (grpc_timer *t)
 
static void list_join (grpc_timer *head, grpc_timer *timer)
 
static void list_remove (grpc_timer *timer)
 
static void note_deadline_change (timer_shard *shard)
 
static grpc_timerpop_one (timer_shard *shard, grpc_core::Timestamp now)
 
static size_t pop_timers (timer_shard *shard, grpc_core::Timestamp now, grpc_core::Timestamp *new_min_deadline, grpc_error_handle error)
 
static bool refill_heap (timer_shard *shard, grpc_core::Timestamp now)
 
static void remove_from_ht (grpc_timer *t)
 
static grpc_timer_check_result run_some_expired_timers (grpc_core::Timestamp now, grpc_core::Timestamp *next, grpc_error_handle error)
 
static void swap_adjacent_shards_in_queue (uint32_t first_shard_queue_index)
 
static void timer_cancel (grpc_timer *timer)
 
static grpc_timer_check_result timer_check (grpc_core::Timestamp *next)
 
static void timer_consume_kick (void)
 
static void timer_init (grpc_timer *timer, grpc_core::Timestamp deadline, grpc_closure *closure)
 
static void timer_list_init ()
 
static void timer_list_shutdown ()
 
static void validate_non_pending_timer (grpc_timer *t)
 

Variables

gpr_spinlock checker_mu
 
static gpr_mu g_hash_mu [NUM_HASH_BUCKETS]
 
static size_t g_num_shards
 
static timer_shard ** g_shard_queue
 
static timer_shardg_shards
 
static struct shared_mutables g_shared_mutables
 
static grpc_timerg_timer_ht [NUM_HASH_BUCKETS] = {nullptr}
 
grpc_timer_vtable grpc_generic_timer_vtable
 
grpc_core::TraceFlag grpc_timer_check_trace (false, "timer_check")
 
grpc_core::TraceFlag grpc_timer_trace (false, "timer")
 
bool initialized
 
grpc_core::Timestamp min_timer
 
gpr_mu mu
 

Macro Definition Documentation

◆ ADD_DEADLINE_SCALE

#define ADD_DEADLINE_SCALE   0.33

Definition at line 45 of file timer_generic.cc.

◆ ADD_TO_HASH_TABLE

#define ADD_TO_HASH_TABLE (   t)    add_to_ht((t))

Definition at line 200 of file timer_generic.cc.

◆ DESTROY_TIMER_HASH_TABLE

#define DESTROY_TIMER_HASH_TABLE ( )    destroy_timer_ht()

Definition at line 199 of file timer_generic.cc.

◆ INIT_TIMER_HASH_TABLE

#define INIT_TIMER_HASH_TABLE ( )    init_timer_ht()

Definition at line 198 of file timer_generic.cc.

◆ INVALID_HEAP_INDEX

#define INVALID_HEAP_INDEX   0xffffffffu

Definition at line 43 of file timer_generic.cc.

◆ MAX_QUEUE_WINDOW_DURATION

#define MAX_QUEUE_WINDOW_DURATION   1.0

Definition at line 47 of file timer_generic.cc.

◆ MIN_QUEUE_WINDOW_DURATION

#define MIN_QUEUE_WINDOW_DURATION   0.01

Definition at line 46 of file timer_generic.cc.

◆ NUM_HASH_BUCKETS

#define NUM_HASH_BUCKETS   1009 /* Prime number close to 1000 */

Definition at line 91 of file timer_generic.cc.

◆ REMOVE_FROM_HASH_TABLE

#define REMOVE_FROM_HASH_TABLE (   t)    remove_from_ht((t))

Definition at line 201 of file timer_generic.cc.

◆ VALIDATE_NON_PENDING_TIMER

#define VALIDATE_NON_PENDING_TIMER (   t)    validate_non_pending_timer((t))

Definition at line 202 of file timer_generic.cc.

Function Documentation

◆ add_to_ht()

static void add_to_ht ( grpc_timer t)
static

Definition at line 121 of file timer_generic.cc.

◆ compute_min_deadline()

static grpc_core::Timestamp compute_min_deadline ( timer_shard shard)
static

Definition at line 236 of file timer_generic.cc.

◆ destroy_timer_ht()

static void destroy_timer_ht ( )
static

Definition at line 102 of file timer_generic.cc.

◆ GPR_ALIGN_STRUCT()

struct shared_mutables GPR_ALIGN_STRUCT ( GPR_CACHELINE_SIZE  )

◆ GPR_THREAD_LOCAL()

static GPR_THREAD_LOCAL ( int64_t  )
static

◆ grpc_timer_init_unset()

void grpc_timer_init_unset ( grpc_timer timer)

Definition at line 330 of file timer_generic.cc.

◆ init_timer_ht()

static void init_timer_ht ( )
static

Definition at line 96 of file timer_generic.cc.

◆ is_in_ht()

static bool is_in_ht ( grpc_timer t)
static

Definition at line 108 of file timer_generic.cc.

◆ list_join()

static void list_join ( grpc_timer head,
grpc_timer timer 
)
static

Definition at line 294 of file timer_generic.cc.

◆ list_remove()

static void list_remove ( grpc_timer timer)
static

Definition at line 300 of file timer_generic.cc.

◆ note_deadline_change()

static void note_deadline_change ( timer_shard shard)
static

Definition at line 317 of file timer_generic.cc.

◆ pop_one()

static grpc_timer* pop_one ( timer_shard shard,
grpc_core::Timestamp  now 
)
static

Definition at line 514 of file timer_generic.cc.

◆ pop_timers()

static size_t pop_timers ( timer_shard shard,
grpc_core::Timestamp  now,
grpc_core::Timestamp new_min_deadline,
grpc_error_handle  error 
)
static

Definition at line 548 of file timer_generic.cc.

◆ refill_heap()

static bool refill_heap ( timer_shard shard,
grpc_core::Timestamp  now 
)
static

Definition at line 473 of file timer_generic.cc.

◆ remove_from_ht()

static void remove_from_ht ( grpc_timer t)
static

Definition at line 147 of file timer_generic.cc.

◆ run_some_expired_timers()

static grpc_timer_check_result run_some_expired_timers ( grpc_core::Timestamp  now,
grpc_core::Timestamp next,
grpc_error_handle  error 
)
static

Definition at line 569 of file timer_generic.cc.

◆ swap_adjacent_shards_in_queue()

static void swap_adjacent_shards_in_queue ( uint32_t  first_shard_queue_index)
static

Definition at line 305 of file timer_generic.cc.

◆ timer_cancel()

static void timer_cancel ( grpc_timer timer)
static

Definition at line 438 of file timer_generic.cc.

◆ timer_check()

static grpc_timer_check_result timer_check ( grpc_core::Timestamp next)
static

Definition at line 668 of file timer_generic.cc.

◆ timer_consume_kick()

static void timer_consume_kick ( void  )
static

Definition at line 433 of file timer_generic.cc.

◆ timer_init()

static void timer_init ( grpc_timer timer,
grpc_core::Timestamp  deadline,
grpc_closure closure 
)
static

Definition at line 332 of file timer_generic.cc.

◆ timer_list_init()

static void timer_list_init ( )
static

Definition at line 243 of file timer_generic.cc.

◆ timer_list_shutdown()

static void timer_list_shutdown ( )
static

Definition at line 275 of file timer_generic.cc.

◆ validate_non_pending_timer()

static void validate_non_pending_timer ( grpc_timer t)
static

Definition at line 185 of file timer_generic.cc.

Variable Documentation

◆ checker_mu

gpr_spinlock checker_mu

Definition at line 222 of file timer_generic.cc.

◆ g_hash_mu

gpr_mu g_hash_mu[NUM_HASH_BUCKETS]
static

Definition at line 93 of file timer_generic.cc.

◆ g_num_shards

size_t g_num_shards
static

Definition at line 76 of file timer_generic.cc.

◆ g_shard_queue

timer_shard** g_shard_queue
static

Definition at line 85 of file timer_generic.cc.

◆ g_shards

timer_shard* g_shards
static

Definition at line 80 of file timer_generic.cc.

◆ g_shared_mutables

struct shared_mutables g_shared_mutables
static

Definition at line 230 of file timer_generic.cc.

◆ g_timer_ht

grpc_timer* g_timer_ht[NUM_HASH_BUCKETS] = {nullptr}
static

Definition at line 94 of file timer_generic.cc.

◆ grpc_generic_timer_vtable

grpc_timer_vtable grpc_generic_timer_vtable

◆ grpc_timer_check_trace

grpc_core::TraceFlag grpc_timer_check_trace(false, "timer_check")

◆ grpc_timer_trace

grpc_core::TraceFlag grpc_timer_trace(false, "timer")

◆ initialized

bool initialized

Definition at line 223 of file timer_generic.cc.

◆ min_timer

Definition at line 220 of file timer_generic.cc.

◆ mu

gpr_mu mu

Definition at line 225 of file timer_generic.cc.

timer_consume_kick
static void timer_consume_kick(void)
Definition: timer_generic.cc:433
timer_init
static void timer_init(grpc_timer *timer, grpc_core::Timestamp deadline, grpc_closure *closure)
Definition: timer_generic.cc:332
timer_cancel
static void timer_cancel(grpc_timer *timer)
Definition: timer_generic.cc:438
timer_check
static grpc_timer_check_result timer_check(grpc_core::Timestamp *next)
Definition: timer_generic.cc:668
timer_list_init
static void timer_list_init()
Definition: timer_generic.cc:243
timer_list_shutdown
static void timer_list_shutdown()
Definition: timer_generic.cc:275


grpc
Author(s):
autogenerated on Fri May 16 2025 03:01:34