mirror of https://github.com/grpc/grpc.git
Merge pull request #8069 from grpc/revert-8068-revert-7279-grand-unified-closures
Revert "Revert "Grand unified closures""pull/7991/head^2
commit
ee43d7bbb1
72 changed files with 2366 additions and 660 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,293 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/combiner.h" |
||||||
|
|
||||||
|
#include <string.h> |
||||||
|
|
||||||
|
#include <grpc/support/alloc.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/workqueue.h" |
||||||
|
#include "src/core/lib/profiling/timers.h" |
||||||
|
|
||||||
|
int grpc_combiner_trace = 0; |
||||||
|
|
||||||
|
#define GRPC_COMBINER_TRACE(fn) \ |
||||||
|
do { \
|
||||||
|
if (grpc_combiner_trace) { \
|
||||||
|
fn; \
|
||||||
|
} \
|
||||||
|
} while (0) |
||||||
|
|
||||||
|
struct grpc_combiner { |
||||||
|
grpc_workqueue *optional_workqueue; |
||||||
|
gpr_mpscq queue; |
||||||
|
// state is:
|
||||||
|
// lower bit - zero if orphaned
|
||||||
|
// other bits - number of items queued on the lock
|
||||||
|
gpr_atm state; |
||||||
|
bool take_async_break_before_final_list; |
||||||
|
grpc_closure_list final_list; |
||||||
|
grpc_closure continue_finishing; |
||||||
|
}; |
||||||
|
|
||||||
|
grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue) { |
||||||
|
grpc_combiner *lock = gpr_malloc(sizeof(*lock)); |
||||||
|
lock->optional_workqueue = optional_workqueue; |
||||||
|
gpr_atm_no_barrier_store(&lock->state, 1); |
||||||
|
gpr_mpscq_init(&lock->queue); |
||||||
|
lock->take_async_break_before_final_list = false; |
||||||
|
grpc_closure_list_init(&lock->final_list); |
||||||
|
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p create", lock)); |
||||||
|
return lock; |
||||||
|
} |
||||||
|
|
||||||
|
static void really_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { |
||||||
|
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, "C:%p really_destroy", lock)); |
||||||
|
GPR_ASSERT(gpr_atm_no_barrier_load(&lock->state) == 0); |
||||||
|
gpr_mpscq_destroy(&lock->queue); |
||||||
|
GRPC_WORKQUEUE_UNREF(exec_ctx, lock->optional_workqueue, "combiner"); |
||||||
|
gpr_free(lock); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { |
||||||
|
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -1); |
||||||
|
GRPC_COMBINER_TRACE(gpr_log( |
||||||
|
GPR_DEBUG, "C:%p really_destroy old_state=%" PRIdPTR, lock, old_state)); |
||||||
|
if (old_state == 1) { |
||||||
|
really_destroy(exec_ctx, lock); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static bool maybe_finish_one(grpc_exec_ctx *exec_ctx, grpc_combiner *lock); |
||||||
|
static void finish(grpc_exec_ctx *exec_ctx, grpc_combiner *lock); |
||||||
|
|
||||||
|
static void continue_finishing_mainline(grpc_exec_ctx *exec_ctx, void *arg, |
||||||
|
grpc_error *error) { |
||||||
|
GPR_TIMER_BEGIN("combiner.continue_executing_mainline", 0); |
||||||
|
grpc_combiner *lock = arg; |
||||||
|
GRPC_COMBINER_TRACE( |
||||||
|
gpr_log(GPR_DEBUG, "C:%p continue_finishing_mainline", lock)); |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == NULL); |
||||||
|
exec_ctx->active_combiner = lock; |
||||||
|
if (maybe_finish_one(exec_ctx, lock)) finish(exec_ctx, lock); |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == lock); |
||||||
|
exec_ctx->active_combiner = NULL; |
||||||
|
GPR_TIMER_END("combiner.continue_executing_mainline", 0); |
||||||
|
} |
||||||
|
|
||||||
|
static void execute_final(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { |
||||||
|
GPR_TIMER_BEGIN("combiner.execute_final", 0); |
||||||
|
grpc_closure *c = lock->final_list.head; |
||||||
|
GPR_ASSERT(c != NULL); |
||||||
|
grpc_closure_list_init(&lock->final_list); |
||||||
|
lock->take_async_break_before_final_list = false; |
||||||
|
int loops = 0; |
||||||
|
while (c != NULL) { |
||||||
|
GRPC_COMBINER_TRACE( |
||||||
|
gpr_log(GPR_DEBUG, "C:%p execute_final[%d] c=%p", lock, loops, c)); |
||||||
|
grpc_closure *next = c->next_data.next; |
||||||
|
grpc_error *error = c->error; |
||||||
|
c->cb(exec_ctx, c->cb_arg, error); |
||||||
|
GRPC_ERROR_UNREF(error); |
||||||
|
c = next; |
||||||
|
loops++; |
||||||
|
} |
||||||
|
GPR_TIMER_END("combiner.execute_final", 0); |
||||||
|
} |
||||||
|
|
||||||
|
static void continue_executing_final(grpc_exec_ctx *exec_ctx, void *arg, |
||||||
|
grpc_error *error) { |
||||||
|
GPR_TIMER_BEGIN("combiner.continue_executing_final", 0); |
||||||
|
grpc_combiner *lock = arg; |
||||||
|
GRPC_COMBINER_TRACE( |
||||||
|
gpr_log(GPR_DEBUG, "C:%p continue_executing_final", lock)); |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == NULL); |
||||||
|
exec_ctx->active_combiner = lock; |
||||||
|
// quick peek to see if new things have turned up on the queue: if so, go back
|
||||||
|
// to executing them before the final list
|
||||||
|
if ((gpr_atm_acq_load(&lock->state) >> 1) > 1) { |
||||||
|
if (maybe_finish_one(exec_ctx, lock)) finish(exec_ctx, lock); |
||||||
|
} else { |
||||||
|
execute_final(exec_ctx, lock); |
||||||
|
finish(exec_ctx, lock); |
||||||
|
} |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == lock); |
||||||
|
exec_ctx->active_combiner = NULL; |
||||||
|
GPR_TIMER_END("combiner.continue_executing_final", 0); |
||||||
|
} |
||||||
|
|
||||||
|
static bool start_execute_final(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { |
||||||
|
GPR_TIMER_BEGIN("combiner.start_execute_final", 0); |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == lock); |
||||||
|
GRPC_COMBINER_TRACE( |
||||||
|
gpr_log(GPR_DEBUG, |
||||||
|
"C:%p start_execute_final take_async_break_before_final_list=%d", |
||||||
|
lock, lock->take_async_break_before_final_list)); |
||||||
|
if (lock->take_async_break_before_final_list) { |
||||||
|
grpc_closure_init(&lock->continue_finishing, continue_executing_final, |
||||||
|
lock); |
||||||
|
grpc_exec_ctx_sched(exec_ctx, &lock->continue_finishing, GRPC_ERROR_NONE, |
||||||
|
GRPC_WORKQUEUE_REF(lock->optional_workqueue, "sched")); |
||||||
|
GPR_TIMER_END("combiner.start_execute_final", 0); |
||||||
|
return false; |
||||||
|
} else { |
||||||
|
execute_final(exec_ctx, lock); |
||||||
|
GPR_TIMER_END("combiner.start_execute_final", 0); |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static bool maybe_finish_one(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { |
||||||
|
GPR_TIMER_BEGIN("combiner.maybe_finish_one", 0); |
||||||
|
gpr_mpscq_node *n = gpr_mpscq_pop(&lock->queue); |
||||||
|
GRPC_COMBINER_TRACE( |
||||||
|
gpr_log(GPR_DEBUG, "C:%p maybe_finish_one n=%p", lock, n)); |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == lock); |
||||||
|
if (n == NULL) { |
||||||
|
// Queue is in an transiently inconsistent state: a new item is being queued
|
||||||
|
// but is not visible to this thread yet.
|
||||||
|
// Use this as a cue that we should go off and do something else for a while
|
||||||
|
// (and come back later)
|
||||||
|
grpc_closure_init(&lock->continue_finishing, continue_finishing_mainline, |
||||||
|
lock); |
||||||
|
grpc_exec_ctx_sched(exec_ctx, &lock->continue_finishing, GRPC_ERROR_NONE, |
||||||
|
GRPC_WORKQUEUE_REF(lock->optional_workqueue, "sched")); |
||||||
|
GPR_TIMER_END("combiner.maybe_finish_one", 0); |
||||||
|
return false; |
||||||
|
} |
||||||
|
grpc_closure *cl = (grpc_closure *)n; |
||||||
|
grpc_error *error = cl->error; |
||||||
|
cl->cb(exec_ctx, cl->cb_arg, error); |
||||||
|
GRPC_ERROR_UNREF(error); |
||||||
|
GPR_TIMER_END("combiner.maybe_finish_one", 0); |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
static void finish(grpc_exec_ctx *exec_ctx, grpc_combiner *lock) { |
||||||
|
bool (*executor)(grpc_exec_ctx * exec_ctx, grpc_combiner * lock); |
||||||
|
GPR_TIMER_BEGIN("combiner.finish", 0); |
||||||
|
int loops = 0; |
||||||
|
do { |
||||||
|
executor = maybe_finish_one; |
||||||
|
gpr_atm old_state = gpr_atm_full_fetch_add(&lock->state, -2); |
||||||
|
GRPC_COMBINER_TRACE(gpr_log(GPR_DEBUG, |
||||||
|
"C:%p finish[%d] old_state=%" PRIdPTR, lock, |
||||||
|
loops, old_state)); |
||||||
|
switch (old_state) { |
||||||
|
default: |
||||||
|
// we have multiple queued work items: just continue executing them
|
||||||
|
break; |
||||||
|
case 5: // we're down to one queued item: if it's the final list we
|
||||||
|
case 4: // should do that
|
||||||
|
if (!grpc_closure_list_empty(lock->final_list)) { |
||||||
|
executor = start_execute_final; |
||||||
|
} |
||||||
|
break; |
||||||
|
case 3: // had one count, one unorphaned --> unlocked unorphaned
|
||||||
|
GPR_TIMER_END("combiner.finish", 0); |
||||||
|
return; |
||||||
|
case 2: // and one count, one orphaned --> unlocked and orphaned
|
||||||
|
really_destroy(exec_ctx, lock); |
||||||
|
GPR_TIMER_END("combiner.finish", 0); |
||||||
|
return; |
||||||
|
case 1: |
||||||
|
case 0: |
||||||
|
// these values are illegal - representing an already unlocked or
|
||||||
|
// deleted lock
|
||||||
|
GPR_UNREACHABLE_CODE(return ); |
||||||
|
} |
||||||
|
loops++; |
||||||
|
} while (executor(exec_ctx, lock)); |
||||||
|
GPR_TIMER_END("combiner.finish", 0); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_combiner_execute(grpc_exec_ctx *exec_ctx, grpc_combiner *lock, |
||||||
|
grpc_closure *cl, grpc_error *error) { |
||||||
|
GRPC_COMBINER_TRACE( |
||||||
|
gpr_log(GPR_DEBUG, "C:%p grpc_combiner_execute c=%p", lock, cl)); |
||||||
|
GPR_TIMER_BEGIN("combiner.execute", 0); |
||||||
|
gpr_atm last = gpr_atm_full_fetch_add(&lock->state, 2); |
||||||
|
GPR_ASSERT(last & 1); // ensure lock has not been destroyed
|
||||||
|
if (last == 1) { |
||||||
|
exec_ctx->active_combiner = lock; |
||||||
|
GPR_TIMER_BEGIN("combiner.execute_first_cb", 0); |
||||||
|
cl->cb(exec_ctx, cl->cb_arg, error); |
||||||
|
GPR_TIMER_END("combiner.execute_first_cb", 0); |
||||||
|
GRPC_ERROR_UNREF(error); |
||||||
|
finish(exec_ctx, lock); |
||||||
|
GPR_ASSERT(exec_ctx->active_combiner == lock); |
||||||
|
exec_ctx->active_combiner = NULL; |
||||||
|
} else { |
||||||
|
cl->error = error; |
||||||
|
gpr_mpscq_push(&lock->queue, &cl->next_data.atm_next); |
||||||
|
} |
||||||
|
GPR_TIMER_END("combiner.execute", 0); |
||||||
|
} |
||||||
|
|
||||||
|
static void enqueue_finally(grpc_exec_ctx *exec_ctx, void *closure, |
||||||
|
grpc_error *error) { |
||||||
|
grpc_combiner_execute_finally(exec_ctx, exec_ctx->active_combiner, closure, |
||||||
|
GRPC_ERROR_REF(error), false); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_combiner_execute_finally(grpc_exec_ctx *exec_ctx, grpc_combiner *lock, |
||||||
|
grpc_closure *closure, grpc_error *error, |
||||||
|
bool force_async_break) { |
||||||
|
GRPC_COMBINER_TRACE(gpr_log( |
||||||
|
GPR_DEBUG, |
||||||
|
"C:%p grpc_combiner_execute_finally c=%p force_async_break=%d; ac=%p", |
||||||
|
lock, closure, force_async_break, exec_ctx->active_combiner)); |
||||||
|
GPR_TIMER_BEGIN("combiner.execute_finally", 0); |
||||||
|
if (exec_ctx->active_combiner != lock) { |
||||||
|
GPR_TIMER_MARK("slowpath", 0); |
||||||
|
grpc_combiner_execute(exec_ctx, lock, |
||||||
|
grpc_closure_create(enqueue_finally, closure), error); |
||||||
|
GPR_TIMER_END("combiner.execute_finally", 0); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (force_async_break) { |
||||||
|
lock->take_async_break_before_final_list = true; |
||||||
|
} |
||||||
|
if (grpc_closure_list_empty(lock->final_list)) { |
||||||
|
gpr_atm_full_fetch_add(&lock->state, 2); |
||||||
|
} |
||||||
|
grpc_closure_list_append(&lock->final_list, closure, error); |
||||||
|
GPR_TIMER_END("combiner.execute_finally", 0); |
||||||
|
} |
||||||
|
|
||||||
|
void grpc_combiner_force_async_finally(grpc_combiner *lock) { |
||||||
|
lock->take_async_break_before_final_list = true; |
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_LIB_IOMGR_COMBINER_H |
||||||
|
#define GRPC_CORE_LIB_IOMGR_COMBINER_H |
||||||
|
|
||||||
|
#include <stddef.h> |
||||||
|
|
||||||
|
#include <grpc/support/atm.h> |
||||||
|
#include "src/core/lib/iomgr/exec_ctx.h" |
||||||
|
#include "src/core/lib/support/mpscq.h" |
||||||
|
|
||||||
|
// Provides serialized access to some resource.
|
||||||
|
// Each action queued on a combiner is executed serially in a borrowed thread.
|
||||||
|
// The actual thread executing actions may change over time (but there will only
|
||||||
|
// every be one at a time).
|
||||||
|
|
||||||
|
// Initialize the lock, with an optional workqueue to shift load to when
|
||||||
|
// necessary
|
||||||
|
grpc_combiner *grpc_combiner_create(grpc_workqueue *optional_workqueue); |
||||||
|
// Destroy the lock
|
||||||
|
void grpc_combiner_destroy(grpc_exec_ctx *exec_ctx, grpc_combiner *lock); |
||||||
|
// Execute \a action within the lock.
|
||||||
|
void grpc_combiner_execute(grpc_exec_ctx *exec_ctx, grpc_combiner *lock, |
||||||
|
grpc_closure *closure, grpc_error *error); |
||||||
|
// Execute \a action within the lock just prior to unlocking.
|
||||||
|
// if \a hint_async_break is true, the combiner tries to hand execution to
|
||||||
|
// another thread before finishing the primary queue of combined closures and
|
||||||
|
// executing the finally list.
|
||||||
|
// Deprecation warning: \a hint_async_break will be removed in a future version
|
||||||
|
// Takes a very slow and round-about path if not called from a
|
||||||
|
// grpc_combiner_execute closure.
|
||||||
|
void grpc_combiner_execute_finally(grpc_exec_ctx *exec_ctx, grpc_combiner *lock, |
||||||
|
grpc_closure *closure, grpc_error *error, |
||||||
|
bool hint_async_break); |
||||||
|
// Deprecated: force the finally list execution onto another thread
|
||||||
|
void grpc_combiner_force_async_finally(grpc_combiner *lock); |
||||||
|
|
||||||
|
extern int grpc_combiner_trace; |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_LIB_IOMGR_COMBINER_H */ |
@ -0,0 +1,83 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/lib/support/mpscq.h" |
||||||
|
|
||||||
|
#include <grpc/support/log.h> |
||||||
|
|
||||||
|
void gpr_mpscq_init(gpr_mpscq *q) { |
||||||
|
gpr_atm_no_barrier_store(&q->head, (gpr_atm)&q->stub); |
||||||
|
q->tail = &q->stub; |
||||||
|
gpr_atm_no_barrier_store(&q->stub.next, (gpr_atm)NULL); |
||||||
|
} |
||||||
|
|
||||||
|
void gpr_mpscq_destroy(gpr_mpscq *q) { |
||||||
|
GPR_ASSERT(gpr_atm_no_barrier_load(&q->head) == (gpr_atm)&q->stub); |
||||||
|
GPR_ASSERT(q->tail == &q->stub); |
||||||
|
} |
||||||
|
|
||||||
|
void gpr_mpscq_push(gpr_mpscq *q, gpr_mpscq_node *n) { |
||||||
|
gpr_atm_no_barrier_store(&n->next, (gpr_atm)NULL); |
||||||
|
gpr_mpscq_node *prev = |
||||||
|
(gpr_mpscq_node *)gpr_atm_full_xchg(&q->head, (gpr_atm)n); |
||||||
|
gpr_atm_rel_store(&prev->next, (gpr_atm)n); |
||||||
|
} |
||||||
|
|
||||||
|
gpr_mpscq_node *gpr_mpscq_pop(gpr_mpscq *q) { |
||||||
|
gpr_mpscq_node *tail = q->tail; |
||||||
|
gpr_mpscq_node *next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next); |
||||||
|
if (tail == &q->stub) { |
||||||
|
// indicates the list is actually (ephemerally) empty
|
||||||
|
if (next == NULL) return NULL; |
||||||
|
q->tail = next; |
||||||
|
tail = next; |
||||||
|
next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next); |
||||||
|
} |
||||||
|
if (next != NULL) { |
||||||
|
q->tail = next; |
||||||
|
return tail; |
||||||
|
} |
||||||
|
gpr_mpscq_node *head = (gpr_mpscq_node *)gpr_atm_acq_load(&q->head); |
||||||
|
if (tail != head) { |
||||||
|
// indicates a retry is in order: we're still adding
|
||||||
|
return NULL; |
||||||
|
} |
||||||
|
gpr_mpscq_push(q, &q->stub); |
||||||
|
next = (gpr_mpscq_node *)gpr_atm_acq_load(&tail->next); |
||||||
|
if (next != NULL) { |
||||||
|
q->tail = next; |
||||||
|
return tail; |
||||||
|
} |
||||||
|
// indicates a retry is in order: we're still adding
|
||||||
|
return NULL; |
||||||
|
} |
@ -0,0 +1,65 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#ifndef GRPC_CORE_LIB_SUPPORT_MPSCQ_H |
||||||
|
#define GRPC_CORE_LIB_SUPPORT_MPSCQ_H |
||||||
|
|
||||||
|
#include <grpc/support/atm.h> |
||||||
|
#include <stddef.h> |
||||||
|
|
||||||
|
// Multiple-producer single-consumer lock free queue, based upon the
|
||||||
|
// implementation from Dmitry Vyukov here:
|
||||||
|
// http://www.1024cores.net/home/lock-free-algorithms/queues/intrusive-mpsc-node-based-queue
|
||||||
|
|
||||||
|
// List node (include this in a data structure at the top, and add application
|
||||||
|
// fields after it - to simulate inheritance)
|
||||||
|
typedef struct gpr_mpscq_node { gpr_atm next; } gpr_mpscq_node; |
||||||
|
|
||||||
|
// Actual queue type
|
||||||
|
typedef struct gpr_mpscq { |
||||||
|
gpr_atm head; |
||||||
|
// make sure head & tail don't share a cacheline
|
||||||
|
char padding[GPR_CACHELINE_SIZE]; |
||||||
|
gpr_mpscq_node *tail; |
||||||
|
gpr_mpscq_node stub; |
||||||
|
} gpr_mpscq; |
||||||
|
|
||||||
|
void gpr_mpscq_init(gpr_mpscq *q); |
||||||
|
void gpr_mpscq_destroy(gpr_mpscq *q); |
||||||
|
// Push a node
|
||||||
|
void gpr_mpscq_push(gpr_mpscq *q, gpr_mpscq_node *n); |
||||||
|
// Pop a node (returns NULL if no node is ready - which doesn't indicate that
|
||||||
|
// the queue is empty!!)
|
||||||
|
gpr_mpscq_node *gpr_mpscq_pop(gpr_mpscq *q); |
||||||
|
|
||||||
|
#endif /* GRPC_CORE_LIB_SUPPORT_MPSCQ_H */ |
@ -0,0 +1,164 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2015, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/lib/iomgr/combiner.h" |
||||||
|
|
||||||
|
#include <grpc/grpc.h> |
||||||
|
#include <grpc/support/alloc.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
#include <grpc/support/thd.h> |
||||||
|
#include <grpc/support/useful.h> |
||||||
|
|
||||||
|
#include "test/core/util/test_config.h" |
||||||
|
|
||||||
|
static void test_no_op(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_no_op"); |
||||||
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||||
|
grpc_combiner_destroy(&exec_ctx, grpc_combiner_create(NULL)); |
||||||
|
grpc_exec_ctx_finish(&exec_ctx); |
||||||
|
} |
||||||
|
|
||||||
|
static void set_bool_to_true(grpc_exec_ctx *exec_ctx, void *value, |
||||||
|
grpc_error *error) { |
||||||
|
*(bool *)value = true; |
||||||
|
} |
||||||
|
|
||||||
|
static void test_execute_one(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_execute_one"); |
||||||
|
|
||||||
|
grpc_combiner *lock = grpc_combiner_create(NULL); |
||||||
|
bool done = false; |
||||||
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||||
|
grpc_combiner_execute(&exec_ctx, lock, |
||||||
|
grpc_closure_create(set_bool_to_true, &done), |
||||||
|
GRPC_ERROR_NONE); |
||||||
|
grpc_exec_ctx_flush(&exec_ctx); |
||||||
|
GPR_ASSERT(done); |
||||||
|
grpc_combiner_destroy(&exec_ctx, lock); |
||||||
|
grpc_exec_ctx_finish(&exec_ctx); |
||||||
|
} |
||||||
|
|
||||||
|
typedef struct { |
||||||
|
size_t ctr; |
||||||
|
grpc_combiner *lock; |
||||||
|
} thd_args; |
||||||
|
|
||||||
|
typedef struct { |
||||||
|
size_t *ctr; |
||||||
|
size_t value; |
||||||
|
} ex_args; |
||||||
|
|
||||||
|
static void check_one(grpc_exec_ctx *exec_ctx, void *a, grpc_error *error) { |
||||||
|
ex_args *args = a; |
||||||
|
GPR_ASSERT(*args->ctr == args->value - 1); |
||||||
|
*args->ctr = args->value; |
||||||
|
gpr_free(a); |
||||||
|
} |
||||||
|
|
||||||
|
static void execute_many_loop(void *a) { |
||||||
|
thd_args *args = a; |
||||||
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||||
|
size_t n = 1; |
||||||
|
for (size_t i = 0; i < 10; i++) { |
||||||
|
for (size_t j = 0; j < 10000; j++) { |
||||||
|
ex_args *c = gpr_malloc(sizeof(*c)); |
||||||
|
c->ctr = &args->ctr; |
||||||
|
c->value = n++; |
||||||
|
grpc_combiner_execute(&exec_ctx, args->lock, |
||||||
|
grpc_closure_create(check_one, c), GRPC_ERROR_NONE); |
||||||
|
grpc_exec_ctx_flush(&exec_ctx); |
||||||
|
} |
||||||
|
// sleep for a little bit, to test a combiner draining and another thread
|
||||||
|
// picking it up
|
||||||
|
gpr_sleep_until(GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100)); |
||||||
|
} |
||||||
|
grpc_exec_ctx_finish(&exec_ctx); |
||||||
|
} |
||||||
|
|
||||||
|
static void test_execute_many(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_execute_many"); |
||||||
|
|
||||||
|
grpc_combiner *lock = grpc_combiner_create(NULL); |
||||||
|
gpr_thd_id thds[100]; |
||||||
|
thd_args ta[GPR_ARRAY_SIZE(thds)]; |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { |
||||||
|
gpr_thd_options options = gpr_thd_options_default(); |
||||||
|
gpr_thd_options_set_joinable(&options); |
||||||
|
ta[i].ctr = 0; |
||||||
|
ta[i].lock = lock; |
||||||
|
GPR_ASSERT(gpr_thd_new(&thds[i], execute_many_loop, &ta[i], &options)); |
||||||
|
} |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { |
||||||
|
gpr_thd_join(thds[i]); |
||||||
|
} |
||||||
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||||
|
grpc_combiner_destroy(&exec_ctx, lock); |
||||||
|
grpc_exec_ctx_finish(&exec_ctx); |
||||||
|
} |
||||||
|
|
||||||
|
static bool got_in_finally = false; |
||||||
|
|
||||||
|
static void in_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { |
||||||
|
got_in_finally = true; |
||||||
|
} |
||||||
|
|
||||||
|
static void add_finally(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { |
||||||
|
grpc_combiner_execute_finally(exec_ctx, arg, |
||||||
|
grpc_closure_create(in_finally, NULL), |
||||||
|
GRPC_ERROR_NONE, false); |
||||||
|
} |
||||||
|
|
||||||
|
static void test_execute_finally(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_execute_finally"); |
||||||
|
|
||||||
|
grpc_combiner *lock = grpc_combiner_create(NULL); |
||||||
|
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; |
||||||
|
grpc_combiner_execute(&exec_ctx, lock, grpc_closure_create(add_finally, lock), |
||||||
|
GRPC_ERROR_NONE); |
||||||
|
grpc_exec_ctx_flush(&exec_ctx); |
||||||
|
GPR_ASSERT(got_in_finally); |
||||||
|
grpc_combiner_destroy(&exec_ctx, lock); |
||||||
|
grpc_exec_ctx_finish(&exec_ctx); |
||||||
|
} |
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
grpc_test_init(argc, argv); |
||||||
|
grpc_init(); |
||||||
|
test_no_op(); |
||||||
|
test_execute_one(); |
||||||
|
test_execute_finally(); |
||||||
|
test_execute_many(); |
||||||
|
grpc_shutdown(); |
||||||
|
|
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,206 @@ |
|||||||
|
/*
|
||||||
|
* |
||||||
|
* Copyright 2016, Google Inc. |
||||||
|
* All rights reserved. |
||||||
|
* |
||||||
|
* Redistribution and use in source and binary forms, with or without |
||||||
|
* modification, are permitted provided that the following conditions are |
||||||
|
* met: |
||||||
|
* |
||||||
|
* * Redistributions of source code must retain the above copyright |
||||||
|
* notice, this list of conditions and the following disclaimer. |
||||||
|
* * Redistributions in binary form must reproduce the above |
||||||
|
* copyright notice, this list of conditions and the following disclaimer |
||||||
|
* in the documentation and/or other materials provided with the |
||||||
|
* distribution. |
||||||
|
* * Neither the name of Google Inc. nor the names of its |
||||||
|
* contributors may be used to endorse or promote products derived from |
||||||
|
* this software without specific prior written permission. |
||||||
|
* |
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
||||||
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
||||||
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
||||||
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
||||||
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||||||
|
* |
||||||
|
*/ |
||||||
|
|
||||||
|
#include "src/core/lib/support/mpscq.h" |
||||||
|
|
||||||
|
#include <stdlib.h> |
||||||
|
|
||||||
|
#include <grpc/support/alloc.h> |
||||||
|
#include <grpc/support/log.h> |
||||||
|
#include <grpc/support/sync.h> |
||||||
|
#include <grpc/support/thd.h> |
||||||
|
#include <grpc/support/useful.h> |
||||||
|
#include "test/core/util/test_config.h" |
||||||
|
|
||||||
|
typedef struct test_node { |
||||||
|
gpr_mpscq_node node; |
||||||
|
size_t i; |
||||||
|
size_t *ctr; |
||||||
|
} test_node; |
||||||
|
|
||||||
|
static test_node *new_node(size_t i, size_t *ctr) { |
||||||
|
test_node *n = gpr_malloc(sizeof(test_node)); |
||||||
|
n->i = i; |
||||||
|
n->ctr = ctr; |
||||||
|
return n; |
||||||
|
} |
||||||
|
|
||||||
|
static void test_serial(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_serial"); |
||||||
|
gpr_mpscq q; |
||||||
|
gpr_mpscq_init(&q); |
||||||
|
for (size_t i = 0; i < 10000000; i++) { |
||||||
|
gpr_mpscq_push(&q, &new_node(i, NULL)->node); |
||||||
|
} |
||||||
|
for (size_t i = 0; i < 10000000; i++) { |
||||||
|
test_node *n = (test_node *)gpr_mpscq_pop(&q); |
||||||
|
GPR_ASSERT(n); |
||||||
|
GPR_ASSERT(n->i == i); |
||||||
|
gpr_free(n); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
typedef struct { |
||||||
|
size_t ctr; |
||||||
|
gpr_mpscq *q; |
||||||
|
gpr_event *start; |
||||||
|
} thd_args; |
||||||
|
|
||||||
|
#define THREAD_ITERATIONS 100000 |
||||||
|
|
||||||
|
static void test_thread(void *args) { |
||||||
|
thd_args *a = args; |
||||||
|
gpr_event_wait(a->start, gpr_inf_future(GPR_CLOCK_REALTIME)); |
||||||
|
for (size_t i = 1; i <= THREAD_ITERATIONS; i++) { |
||||||
|
gpr_mpscq_push(a->q, &new_node(i, &a->ctr)->node); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static void test_mt(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_mt"); |
||||||
|
gpr_event start; |
||||||
|
gpr_event_init(&start); |
||||||
|
gpr_thd_id thds[100]; |
||||||
|
thd_args ta[GPR_ARRAY_SIZE(thds)]; |
||||||
|
gpr_mpscq q; |
||||||
|
gpr_mpscq_init(&q); |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { |
||||||
|
gpr_thd_options options = gpr_thd_options_default(); |
||||||
|
gpr_thd_options_set_joinable(&options); |
||||||
|
ta[i].ctr = 0; |
||||||
|
ta[i].q = &q; |
||||||
|
ta[i].start = &start; |
||||||
|
GPR_ASSERT(gpr_thd_new(&thds[i], test_thread, &ta[i], &options)); |
||||||
|
} |
||||||
|
size_t num_done = 0; |
||||||
|
size_t spins = 0; |
||||||
|
gpr_event_set(&start, (void *)1); |
||||||
|
while (num_done != GPR_ARRAY_SIZE(thds)) { |
||||||
|
gpr_mpscq_node *n; |
||||||
|
while ((n = gpr_mpscq_pop(&q)) == NULL) { |
||||||
|
spins++; |
||||||
|
} |
||||||
|
test_node *tn = (test_node *)n; |
||||||
|
GPR_ASSERT(*tn->ctr == tn->i - 1); |
||||||
|
*tn->ctr = tn->i; |
||||||
|
if (tn->i == THREAD_ITERATIONS) num_done++; |
||||||
|
gpr_free(tn); |
||||||
|
} |
||||||
|
gpr_log(GPR_DEBUG, "spins: %" PRIdPTR, spins); |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { |
||||||
|
gpr_thd_join(thds[i]); |
||||||
|
} |
||||||
|
gpr_mpscq_destroy(&q); |
||||||
|
} |
||||||
|
|
||||||
|
typedef struct { |
||||||
|
thd_args *ta; |
||||||
|
size_t num_thds; |
||||||
|
gpr_mu mu; |
||||||
|
size_t num_done; |
||||||
|
size_t spins; |
||||||
|
gpr_mpscq *q; |
||||||
|
gpr_event *start; |
||||||
|
} pull_args; |
||||||
|
|
||||||
|
static void pull_thread(void *arg) { |
||||||
|
pull_args *pa = arg; |
||||||
|
gpr_event_wait(pa->start, gpr_inf_future(GPR_CLOCK_REALTIME)); |
||||||
|
|
||||||
|
for (;;) { |
||||||
|
gpr_mu_lock(&pa->mu); |
||||||
|
if (pa->num_done == pa->num_thds) { |
||||||
|
gpr_mu_unlock(&pa->mu); |
||||||
|
return; |
||||||
|
} |
||||||
|
gpr_mpscq_node *n; |
||||||
|
while ((n = gpr_mpscq_pop(pa->q)) == NULL) { |
||||||
|
pa->spins++; |
||||||
|
} |
||||||
|
test_node *tn = (test_node *)n; |
||||||
|
GPR_ASSERT(*tn->ctr == tn->i - 1); |
||||||
|
*tn->ctr = tn->i; |
||||||
|
if (tn->i == THREAD_ITERATIONS) pa->num_done++; |
||||||
|
gpr_free(tn); |
||||||
|
gpr_mu_unlock(&pa->mu); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
static void test_mt_multipop(void) { |
||||||
|
gpr_log(GPR_DEBUG, "test_mt_multipop"); |
||||||
|
gpr_event start; |
||||||
|
gpr_event_init(&start); |
||||||
|
gpr_thd_id thds[100]; |
||||||
|
gpr_thd_id pull_thds[100]; |
||||||
|
thd_args ta[GPR_ARRAY_SIZE(thds)]; |
||||||
|
gpr_mpscq q; |
||||||
|
gpr_mpscq_init(&q); |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { |
||||||
|
gpr_thd_options options = gpr_thd_options_default(); |
||||||
|
gpr_thd_options_set_joinable(&options); |
||||||
|
ta[i].ctr = 0; |
||||||
|
ta[i].q = &q; |
||||||
|
ta[i].start = &start; |
||||||
|
GPR_ASSERT(gpr_thd_new(&thds[i], test_thread, &ta[i], &options)); |
||||||
|
} |
||||||
|
pull_args pa; |
||||||
|
pa.ta = ta; |
||||||
|
pa.num_thds = GPR_ARRAY_SIZE(thds); |
||||||
|
pa.spins = 0; |
||||||
|
pa.num_done = 0; |
||||||
|
pa.q = &q; |
||||||
|
pa.start = &start; |
||||||
|
gpr_mu_init(&pa.mu); |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) { |
||||||
|
gpr_thd_options options = gpr_thd_options_default(); |
||||||
|
gpr_thd_options_set_joinable(&options); |
||||||
|
GPR_ASSERT(gpr_thd_new(&pull_thds[i], pull_thread, &pa, &options)); |
||||||
|
} |
||||||
|
gpr_event_set(&start, (void *)1); |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(pull_thds); i++) { |
||||||
|
gpr_thd_join(pull_thds[i]); |
||||||
|
} |
||||||
|
gpr_log(GPR_DEBUG, "spins: %" PRIdPTR, pa.spins); |
||||||
|
for (size_t i = 0; i < GPR_ARRAY_SIZE(thds); i++) { |
||||||
|
gpr_thd_join(thds[i]); |
||||||
|
} |
||||||
|
gpr_mpscq_destroy(&q); |
||||||
|
} |
||||||
|
|
||||||
|
int main(int argc, char **argv) { |
||||||
|
grpc_test_init(argc, argv); |
||||||
|
test_serial(); |
||||||
|
test_mt(); |
||||||
|
test_mt_multipop(); |
||||||
|
return 0; |
||||||
|
} |
@ -0,0 +1,199 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" /> |
||||||
|
<ItemGroup Label="ProjectConfigurations"> |
||||||
|
<ProjectConfiguration Include="Debug|Win32"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Debug|x64"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|Win32"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|x64"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
</ItemGroup> |
||||||
|
<PropertyGroup Label="Globals"> |
||||||
|
<ProjectGuid>{C237D1E4-8825-80BA-1FC3-5E147E53E96E}</ProjectGuid> |
||||||
|
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||||
|
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v100</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v110</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v120</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v140</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>true</UseDebugLibraries> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>false</UseDebugLibraries> |
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||||
|
<ImportGroup Label="ExtensionSettings"> |
||||||
|
</ImportGroup> |
||||||
|
<ImportGroup Label="PropertySheets"> |
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" /> |
||||||
|
</ImportGroup> |
||||||
|
<PropertyGroup Label="UserMacros" /> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||||
|
<TargetName>combiner_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||||
|
<TargetName>combiner_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\core\iomgr\combiner_test.c"> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc_test_util\grpc_test_util.vcxproj"> |
||||||
|
<Project>{17BCAFC0-5FDC-4C94-AEB9-95F3E220614B}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\grpc\grpc.vcxproj"> |
||||||
|
<Project>{29D16885-7228-4C31-81ED-5F9187C7F2A9}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj"> |
||||||
|
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||||
|
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<None Include="packages.config" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||||
|
<ImportGroup Label="ExtensionTargets"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
</ImportGroup> |
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||||
|
<PropertyGroup> |
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||||
|
</PropertyGroup> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" /> |
||||||
|
</Target> |
||||||
|
</Project> |
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\core\iomgr\combiner_test.c"> |
||||||
|
<Filter>test\core\iomgr</Filter> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Filter Include="test"> |
||||||
|
<UniqueIdentifier>{82bca2af-d499-b405-fd05-4d345372496c}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\core"> |
||||||
|
<UniqueIdentifier>{c32d8e20-b719-532d-ba23-bd9d523fac15}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\core\iomgr"> |
||||||
|
<UniqueIdentifier>{b4fa8ca1-e6c7-dec5-6d62-8a62396825c6}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
</ItemGroup> |
||||||
|
</Project> |
||||||
|
|
@ -0,0 +1,193 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\1.0.204.1.props')" /> |
||||||
|
<ItemGroup Label="ProjectConfigurations"> |
||||||
|
<ProjectConfiguration Include="Debug|Win32"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Debug|x64"> |
||||||
|
<Configuration>Debug</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|Win32"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>Win32</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
<ProjectConfiguration Include="Release|x64"> |
||||||
|
<Configuration>Release</Configuration> |
||||||
|
<Platform>x64</Platform> |
||||||
|
</ProjectConfiguration> |
||||||
|
</ItemGroup> |
||||||
|
<PropertyGroup Label="Globals"> |
||||||
|
<ProjectGuid>{B3D7760B-8BEA-2EF6-F1D4-9F9020E166D6}</ProjectGuid> |
||||||
|
<IgnoreWarnIntDirInTempDetected>true</IgnoreWarnIntDirInTempDetected> |
||||||
|
<IntDir>$(SolutionDir)IntDir\$(MSBuildProjectName)\</IntDir> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '10.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v100</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '11.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v110</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '12.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v120</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(VisualStudioVersion)' == '14.0'" Label="Configuration"> |
||||||
|
<PlatformToolset>v140</PlatformToolset> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>true</UseDebugLibraries> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration"> |
||||||
|
<ConfigurationType>Application</ConfigurationType> |
||||||
|
<UseDebugLibraries>false</UseDebugLibraries> |
||||||
|
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||||
|
<CharacterSet>Unicode</CharacterSet> |
||||||
|
</PropertyGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||||
|
<ImportGroup Label="ExtensionSettings"> |
||||||
|
</ImportGroup> |
||||||
|
<ImportGroup Label="PropertySheets"> |
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\global.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\openssl.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\winsock.props" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\zlib.props" /> |
||||||
|
</ImportGroup> |
||||||
|
<PropertyGroup Label="UserMacros" /> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> |
||||||
|
<TargetName>gpr_mpscq_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Debug</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Debug</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<PropertyGroup Condition="'$(Configuration)'=='Release'"> |
||||||
|
<TargetName>gpr_mpscq_test</TargetName> |
||||||
|
<Linkage-grpc_dependencies_zlib>static</Linkage-grpc_dependencies_zlib> |
||||||
|
<Configuration-grpc_dependencies_zlib>Release</Configuration-grpc_dependencies_zlib> |
||||||
|
<Linkage-grpc_dependencies_openssl>static</Linkage-grpc_dependencies_openssl> |
||||||
|
<Configuration-grpc_dependencies_openssl>Release</Configuration-grpc_dependencies_openssl> |
||||||
|
</PropertyGroup> |
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>Disabled</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> |
||||||
|
<ClCompile> |
||||||
|
<PrecompiledHeader>NotUsing</PrecompiledHeader> |
||||||
|
<WarningLevel>Level3</WarningLevel> |
||||||
|
<Optimization>MaxSpeed</Optimization> |
||||||
|
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||||
|
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||||
|
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||||
|
<SDLCheck>true</SDLCheck> |
||||||
|
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> |
||||||
|
<TreatWarningAsError>true</TreatWarningAsError> |
||||||
|
<DebugInformationFormat Condition="$(Jenkins)">None</DebugInformationFormat> |
||||||
|
<MinimalRebuild Condition="$(Jenkins)">false</MinimalRebuild> |
||||||
|
</ClCompile> |
||||||
|
<Link> |
||||||
|
<SubSystem>Console</SubSystem> |
||||||
|
<GenerateDebugInformation Condition="!$(Jenkins)">true</GenerateDebugInformation> |
||||||
|
<GenerateDebugInformation Condition="$(Jenkins)">false</GenerateDebugInformation> |
||||||
|
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||||
|
<OptimizeReferences>true</OptimizeReferences> |
||||||
|
</Link> |
||||||
|
</ItemDefinitionGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\core\support\mpscq_test.c"> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr_test_util\gpr_test_util.vcxproj"> |
||||||
|
<Project>{EAB0A629-17A9-44DB-B5FF-E91A721FE037}</Project> |
||||||
|
</ProjectReference> |
||||||
|
<ProjectReference Include="$(SolutionDir)\..\vsprojects\vcxproj\.\gpr\gpr.vcxproj"> |
||||||
|
<Project>{B23D3D1A-9438-4EDA-BEB6-9A0A03D17792}</Project> |
||||||
|
</ProjectReference> |
||||||
|
</ItemGroup> |
||||||
|
<ItemGroup> |
||||||
|
<None Include="packages.config" /> |
||||||
|
</ItemGroup> |
||||||
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||||
|
<ImportGroup Label="ExtensionTargets"> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
<Import Project="$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets" Condition="Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies\grpc.dependencies.openssl.targets')" /> |
||||||
|
</ImportGroup> |
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
||||||
|
<PropertyGroup> |
||||||
|
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
||||||
|
</PropertyGroup> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.redist.1.2.8.10\build\native\grpc.dependencies.zlib.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.zlib.1.2.8.10\build\native\grpc.dependencies.zlib.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.redist.1.0.204.1\build\native\grpc.dependencies.openssl.redist.targets')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.props')" /> |
||||||
|
<Error Condition="!Exists('$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\..\vsprojects\packages\grpc.dependencies.openssl.1.0.204.1\build\native\grpc.dependencies.openssl.targets')" /> |
||||||
|
</Target> |
||||||
|
</Project> |
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||||
|
<ItemGroup> |
||||||
|
<ClCompile Include="$(SolutionDir)\..\test\core\support\mpscq_test.c"> |
||||||
|
<Filter>test\core\support</Filter> |
||||||
|
</ClCompile> |
||||||
|
</ItemGroup> |
||||||
|
|
||||||
|
<ItemGroup> |
||||||
|
<Filter Include="test"> |
||||||
|
<UniqueIdentifier>{e82fb80c-10ba-2959-55d6-8653715f1e4f}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\core"> |
||||||
|
<UniqueIdentifier>{32120233-25e6-f3e4-f828-c6408d47ec04}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
<Filter Include="test\core\support"> |
||||||
|
<UniqueIdentifier>{aa3a22bc-229a-c00a-dd4a-924c818c6a49}</UniqueIdentifier> |
||||||
|
</Filter> |
||||||
|
</ItemGroup> |
||||||
|
</Project> |
||||||
|
|
Loading…
Reference in new issue