MCPcopy Create free account
hub / github.com/apache/brpc / bthread_sem_post

Function bthread_sem_post

src/bthread/semaphore.cpp:111–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109}
110
111static inline int bthread_sem_post(bthread_sem_t* sem, size_t num) {
112 if (num > 0) {
113 unsigned n = ((butil::atomic<unsigned>*)sem->butex)
114 ->fetch_add(num, butil::memory_order_relaxed);
115 const size_t sampling_range = NULL != bthread::g_cp && sem->enable_csite ?
116 bvar::is_collectable(&bthread::g_cp_sl) : bvar::INVALID_SAMPLING_RANGE;
117 const int64_t start_ns = bvar::is_sampling_range_valid(sampling_range) ?
118 butil::cpuwide_time_ns() : -1;
119 bthread::butex_wake_n(sem->butex, n);
120 if (start_ns > 0) {
121 const int64_t end_ns = butil::cpuwide_time_ns();
122 const bthread_contention_site_t csite{end_ns - start_ns, sampling_range};
123 bthread::submit_contention(csite, end_ns);
124 }
125 }
126 return 0;
127}
128
129} // namespace bthread
130

Callers 5

sem_posterFunction · 0.85
TESTFunction · 0.85
post_opFunction · 0.85
rwlock_unrdlockFunction · 0.85
bthread_sem_post_nFunction · 0.85

Calls 6

is_collectableFunction · 0.85
is_sampling_range_validFunction · 0.85
cpuwide_time_nsFunction · 0.85
butex_wake_nFunction · 0.85
submit_contentionFunction · 0.85
fetch_addMethod · 0.80

Tested by 3

sem_posterFunction · 0.68
TESTFunction · 0.68
post_opFunction · 0.68