Go to the documentation of this file.
77 while (q->length ==
N) {
85 q->elem[(q->head + q->length) %
N] =
x;
99 q->elem[(q->head + q->length) %
N] =
x;
119 while (q->length == 0 && !
gpr_cv_wait(&q->non_empty, &q->mu, abs_deadline)) {
121 if (q->length != 0) {
123 if (q->length ==
N) {
126 *head = q->elem[q->head];
127 q->head = (q->head + 1) %
N;
196 for (
i = 0;
i !=
m->nthreads;
i++) {
198 m->threads[
i].Start();
205 while (
m->done != 0) {
209 for (
int i = 0;
i !=
m->nthreads;
i++) {
210 m->threads[
i].Join();
218 id =
m->thread_count++;
241 static void test(
const char*
name,
void (*body)(
void*
m),
242 void (*extra)(
void*
m),
int timeout_s,
int incr_step) {
257 if (extra !=
nullptr) {
264 if (extra !=
nullptr) {
267 if (
m->counter !=
m->nthreads *
m->iterations *
m->incr_step) {
268 fprintf(
stderr,
"counter %ld threads %d iterations %ld\n",
269 static_cast<long>(
m->counter),
m->nthreads,
270 static_cast<long>(
m->iterations));
278 fprintf(
stderr,
" done %lld.%09d s\n",
288 for (
i = 0;
i !=
m->iterations;
i++) {
301 for (
i = 0;
i !=
m->iterations;) {
317 for (
i = 0;
i !=
m->iterations;
i++) {
319 while ((
m->counter %
m->nthreads) !=
id) {
334 for (
i = 0;
i !=
m->iterations;
i++) {
352 for (
i = 0;
i !=
m->iterations;
i++) {
372 for (
i = 0;
i !=
m->iterations;
i++) {
376 for (
i = 0;
i !=
m->iterations;
i++) {
392 for (
i = 0;
i !=
n;
i++) {
410 for (
i = 0;
i !=
m->iterations;
i++) {
425 for (
i = 0;
i !=
m->iterations;
i++) {
426 if (
m->incr_step == 1) {
443 int64_t n =
m->iterations *
m->nthreads *
m->incr_step;
448 for (
i = 1;
i !=
n;
i++) {
459 int main(
int argc,
char* argv[]) {
461 test(
"mutex", &
inc,
nullptr, 1, 1);
GPRAPI void gpr_cv_signal(gpr_cv *cv)
GPRAPI void gpr_mu_unlock(gpr_mu *mu)
gpr_stats_counter stats_counter
GPRAPI void gpr_refn(gpr_refcount *r, int n)
GPRAPI void * gpr_event_get(gpr_event *ev)
GPRAPI void gpr_event_set(gpr_event *ev, void *value)
GPRAPI void gpr_free(void *ptr)
GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter *c)
void queue_init(queue *q)
GPRAPI void * gpr_malloc(size_t size)
static void refcheck(void *v)
GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type)
static void test(const char *name, void(*body)(void *m), void(*extra)(void *m), int timeout_s, int incr_step)
static void refinc(void *v)
static void inc_with_1ms_delay_event(void *v)
int queue_remove(queue *q, int *head, gpr_timespec abs_deadline)
GPRAPI void gpr_stats_init(gpr_stats_counter *c, intptr_t n)
GPRAPI void gpr_mu_destroy(gpr_mu *mu)
static void many_producers(void *v)
void queue_destroy(queue *q)
GPRAPI int gpr_time_cmp(gpr_timespec a, gpr_timespec b)
GPRAPI void gpr_cv_destroy(gpr_cv *cv)
GPRAPI gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b)
GPRAPI void gpr_mu_init(gpr_mu *mu)
static void inc_with_1ms_delay(void *v)
static void test_wait(struct test *m)
static void consumer(void *v)
GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline)
static void inctry(void *v)
static void test_create_threads(struct test *m, void(*body)(void *arg))
GPRAPI void gpr_mu_lock(gpr_mu *mu)
GPRAPI void gpr_event_init(gpr_event *ev)
static unsigned int nthreads
int main(int argc, char *argv[])
static void mark_thread_done(struct test *m)
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
GPRAPI void * gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline)
static struct test * test_new(int nthreads, int64_t iterations, int incr_step)
int queue_try_append(queue *q, int x)
gpr_refcount thread_refcount
static int thread_id(struct test *m)
void queue_append(queue *q, int x)
GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b)
static void inc_by_turns(void *v)
GPRAPI int gpr_mu_trylock(gpr_mu *mu)
GPRAPI gpr_timespec gpr_time_from_micros(int64_t us, gpr_clock_type clock_type)
GPRAPI void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc)
static void statsinc(void *v)
grpc_core::Thread * threads
static void test_destroy(struct test *m)
GPRAPI void gpr_cv_broadcast(gpr_cv *cv)
GPRAPI void gpr_ref_init(gpr_refcount *r, int n)
GPRAPI int gpr_unref(gpr_refcount *r)
GPRAPI void gpr_ref(gpr_refcount *r)
GPRAPI void gpr_cv_init(gpr_cv *cv)
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:24