Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit b0fbf0ff36132a33810eb515b271b08518dc9f6a 1 parent 94d79c9
Sergey Avseyev avsej authored trondn committed
Showing with 13 additions and 6 deletions.
  1. +13 −6 example/pillowfight/pillowfight.cc
19 example/pillowfight/pillowfight.cc
View
@@ -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) {
Please sign in to comment.
Something went wrong with that request. Please try again.