Permalink
Browse files

pillowfight.cc: allow to share IO object in single-threaded mode only

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...
1 parent 94d79c9 commit b0fbf0ff36132a33810eb515b271b08518dc9f6a @avsej avsej committed with trondn Mar 12, 2013
Showing with 13 additions and 6 deletions.
  1. +13 −6 example/pillowfight/pillowfight.cc
@@ -134,6 +134,10 @@ class Configuration
numThreads = val;
}
+ uint32_t getNumThreads() {
+ return numThreads;
+ }
+
void setNumInstances(uint32_t val) {
numInstances = val;
}
@@ -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) {

0 comments on commit b0fbf0f

Please sign in to comment.