Skip to content

Commit

Permalink
pillowfight.cc: allow to share IO object in single-threaded mode only
Browse files Browse the repository at this point in the history
Change-Id: Ib4395624cdb4a710b391d89a50cf3a2b2bb6ad35
Reviewed-on: http://review.couchbase.org/25105
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Trond Norbye <trond.norbye@gmail.com>
  • Loading branch information
avsej authored and trondn committed Mar 12, 2013
1 parent 94d79c9 commit b0fbf0f
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions example/pillowfight/pillowfight.cc
Expand Up @@ -134,6 +134,10 @@ class Configuration
numThreads = val;
}

uint32_t getNumThreads() {
return numThreads;
}

void setNumInstances(uint32_t val) {
numInstances = val;
}
Expand Down Expand Up @@ -194,12 +198,15 @@ extern "C" {
class InstancePool
{
public:
InstancePool(size_t size) {
lcb_error_t err = lcb_create_io_ops(&io, NULL);
if (err != LCB_SUCCESS) {
std::cerr << "Failed to create IO option: "
<< lcb_strerror(NULL, err) << std::endl;
exit(EXIT_FAILURE);
InstancePool(size_t size): io(NULL) {
if (config.getNumThreads() == 1) {
/* allow to share IO object in single-thread only */
lcb_error_t err = lcb_create_io_ops(&io, NULL);
if (err != LCB_SUCCESS) {
std::cerr << "Failed to create IO option: "
<< lcb_strerror(NULL, err) << std::endl;
exit(EXIT_FAILURE);
}
}

for (size_t ii = 0; ii < size; ++ii) {
Expand Down

0 comments on commit b0fbf0f

Please sign in to comment.