int DDLT::Select::PushNew( lua_State* L, DDLParser::Definition* definition, DDLParser::Select* select ) { Select* self = new ( lua_newuserdata( L, sizeof( Select ) ) ) Select; if ( !self->Init( definition, select ) ) { return luaL_error( L, "Error creating DDLT::Select" ); } if ( luaL_newmetatable( L, "DDLT::Select" ) ) { lua_pushcfunction( L, getNumItems ); lua_setfield( L, -2, "__len" ); lua_pushcfunction( L, l__index ); lua_setfield( L, -2, "__index" ); lua_pushcfunction( L, l__gc ); lua_setfield( L, -2, "__gc" ); lua_pushcfunction( L, l__eq ); lua_setfield( L, -2, "__eq" ); lua_pushcfunction( L, l__tostring ); lua_setfield( L, -2, "__tostring" ); } lua_setmetatable( L, -2 ); return 1; }
int DDLT::Select::l__gc( lua_State* L ) { Select* self = Check( L, 1 ); self->Destroy(); return 0; }
[[ noreturn ]] void Logger::settingThread() { Select select; DBConnector db(LOGLEVEL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); std::vector<std::shared_ptr<ConsumerStateTable>> selectables(m_settingChangeObservers.size()); for (const auto& i : m_settingChangeObservers) { std::shared_ptr<ConsumerStateTable> table = std::make_shared<ConsumerStateTable>(&db, i.first); selectables.push_back(table); select.addSelectable(table.get()); } while(true) { Selectable *selectable = nullptr; int ret = select.select(&selectable); if (ret == Select::ERROR) { SWSS_LOG_NOTICE("%s select error %s", __PRETTY_FUNCTION__, strerror(errno)); continue; } KeyOpFieldsValuesTuple koValues; dynamic_cast<ConsumerStateTable *>(selectable)->pop(koValues); std::string key = kfvKey(koValues), op = kfvOp(koValues); if ((op != SET_COMMAND) || (m_settingChangeObservers.find(key) == m_settingChangeObservers.end())) { continue; } auto values = kfvFieldsValues(koValues); for (const auto& i : values) { const std::string &field = fvField(i), &value = fvValue(i); if ((field == DAEMON_LOGLEVEL) && (value != m_currentPrios[key])) { m_currentPrios[key] = value; m_settingChangeObservers[key].first(key, value); } else if ((field == DAEMON_LOGOUTPUT) && (value != m_currentOutputs[key])) { m_currentOutputs[key] = value; m_settingChangeObservers[key].second(key, value); } break; } } }
TEST(ConsumerStateTable, set_del) { clearDB(); /* Prepare producer */ int index = 0; string tableName = "UT_REDIS_THREAD_" + to_string(index); DBConnector db(TEST_VIEW, "localhost", 6379, 0); ProducerStateTable p(&db, tableName); string key = "TheKey"; int maxNumOfFields = 2; /* Set operation */ { vector<FieldValueTuple> fields; for (int j = 0; j < maxNumOfFields; j++) { FieldValueTuple t(field(j), value(j)); fields.push_back(t); } p.set(key, fields); } /* Del operation */ p.del(key); /* Prepare consumer */ ConsumerStateTable c(&db, tableName); Select cs; Selectable *selectcs; cs.addSelectable(&c); int tmpfd; /* First pop operation */ { int ret = cs.select(&selectcs, &tmpfd); EXPECT_TRUE(ret == Select::OBJECT); KeyOpFieldsValuesTuple kco; c.pop(kco); EXPECT_TRUE(kfvKey(kco) == key); EXPECT_TRUE(kfvOp(kco) == "DEL"); auto fvs = kfvFieldsValues(kco); EXPECT_EQ(fvs.size(), 0U); } /* Second select operation */ { int ret = cs.select(&selectcs, &tmpfd, 1000); EXPECT_TRUE(ret == Select::TIMEOUT); } }
Expr select( Expr cond, Expr ok, Expr ko ) { if ( ok == ko ) return ok; if ( cond->always( true ) ) return ok; if ( cond->always( false ) ) return ko; if ( cond->op_type() == ID_OP_not_boolean ) return select( cond->inp[ 0 ], ko, ok ); Select *res = new Select; res->add_inp( cond ); res->add_inp( ok ); res->add_inp( ko ); return Inst::twin_or_val( res ); }
void CDBirthdayController::fetchTrackerIds() { // keep in sync with the enum in the header and NTrackerIds const QList<ResourceValue> resources = QList<ResourceValue>() << nco::birthDate::resource() << rdf::type::resource() << nco::PersonContact::resource() << nco::ContactGroup::resource(); Select select; foreach (const ResourceValue &value, resources) { select.addProjection(Functions::trackerId.apply(value)); }
int main(int argc, char **argv) { swss::Logger::linkToDbNative("fpmsyncd"); DBConnector db(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0); RedisPipeline pipeline(&db); RouteSync sync(&pipeline); NetDispatcher::getInstance().registerMessageHandler(RTM_NEWROUTE, &sync); NetDispatcher::getInstance().registerMessageHandler(RTM_DELROUTE, &sync); while (1) { try { FpmLink fpm; Select s; cout << "Waiting for connection..." << endl; fpm.accept(); cout << "Connected!" << endl; s.addSelectable(&fpm); while (true) { Selectable *temps; int tempfd; /* Reading FPM messages forever (and calling "readMe" to read them) */ s.select(&temps, &tempfd); pipeline.flush(); SWSS_LOG_DEBUG("Pipeline flushed"); } } catch (FpmLink::FpmConnectionClosedException &e) { cout << "Connection lost, reconnecting..." << endl; } catch (const exception& e) { cout << "Exception \"" << e.what() << "\" had been thrown in deamon" << endl; return 0; } } return 1; }
static void consumerWorker(int index) { string tableName = "UT_REDIS_THREAD_" + to_string(index); DBConnector db(TEST_VIEW, "localhost", 6379, 0); ConsumerStateTable c(&db, tableName); Select cs; Selectable *selectcs; int tmpfd; int numberOfKeysSet = 0; int numberOfKeyDeleted = 0; int ret, i = 0; KeyOpFieldsValuesTuple kco; cs.addSelectable(&c); while ((ret = cs.select(&selectcs, &tmpfd)) == Select::OBJECT) { c.pop(kco); if (kfvOp(kco) == "SET") { numberOfKeysSet++; validateFields(kfvKey(kco), kfvFieldsValues(kco)); } else if (kfvOp(kco) == "DEL") { numberOfKeyDeleted++; } if ((i++ % 100) == 0) cout << "-" << flush; if (numberOfKeyDeleted == NUMBER_OF_OPS) break; } EXPECT_TRUE(numberOfKeysSet <= numberOfKeyDeleted); EXPECT_EQ(ret, Selectable::DATA); }
void test_select_random_access(const Select& select, bit_vector::size_type args, bit_vector::size_type times) { typedef bit_vector::size_type size_type; const int s = 20; const uint64_t mask = (1<<s)-1; int_vector<64> rands(1<<s ,0); util::set_random_bits(rands, 17); util::all_elements_mod(rands, args); for (size_type i=0; i<rands.size(); ++i) rands[i] = rands[i]+1; size_type cnt=0; write_R_output("select","random access","begin",times,cnt); for (size_type i=0; i<times; ++i) { cnt += select.select(rands[ i&mask ]); } write_R_output("select","random access","end",times,cnt); }
int main() { int size = 8; int a1[] = {4, 8, 2, 1, 3, 5, 6, 7}; Select s; for (int i = 0; i < size; i++) { assert(s.select(a1, size, i) == i + 1); } size = 5; int a2[] = {5, 4, 3, 2, 1}; for (int i = 0; i < size; i++) { assert(s.select(a2, size, i) == i + 1); } size = 10; int a3[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; for (int i = 0; i < size; i++) { assert(s.select(a3, size, i) == i + 1); } size = 1; int a5[] = { 1 }; for (int i = 0; i < size; i++) { assert(s.select(a5, size, i) == i + 1); } size = 2; int a6[] = {2, 1}; for (int i = 0; i < size; i++) { assert(s.select(a6, size, i) == i + 1); } return 0; }
GenericStep::GenericStep( bool isInput_in, QString ID_in, vector<StepGenericElement*> elements_in, QWidget *parent) : QWidget(parent) { ui.setupUi(this); inputStep = isInput_in; ID = ID_in; QVBoxLayout * mainLayout = new QVBoxLayout(); StepGenericElement * currentElement; //Loop through the elements for(int i = 0; i<elements_in.size(); i++){ currentElement = elements_in.at(i); if(currentElement != 0){ //Check the type of element switch(currentElement->getElementName()){ case TEXT: Text * textElement = dynamic_cast<Text*>(currentElement); //Generating area where to insert the text QScrollArea * scrollArea = new QScrollArea(); scrollArea->setWidgetResizable(true); //if(textElement->getWidth() != 0) //scrollArea->setFixedWidth(textElement->getWidth()); //if(textElement->getRows() != 0) //scrollArea->setFixedHeight(textElement->getRows()); QLabel *description = new QLabel(textElement->getContent(), this); description->setWordWrap(true); description->setAlignment(Qt::AlignJustify); scrollArea->setWidget(description); mainLayout->addWidget(scrollArea); break; case INPUTFIELD: Input * inputElement = dynamic_cast<Input*>(currentElement); //Generating a gridlayout where to put both the label and the field QGridLayout * inputContainerLayout = new QGridLayout(this); QWidget * inputContainer = new QWidget(this); QLabel * inputLabel = new QLabel(inputElement->getLabel(),this); QTextEdit * inputText = new QTextEdit(inputElement->getContent(),this); inputText->setObjectName(inputElement->getId()); inputElements.push_back(inputText); if(inputElement->getWidth() != 0) inputText->setFixedHeight(inputElement->getWidth()); if(inputElement->getRows() != 0) inputText->setFixedHeight(inputElement->getRows()*20); switch(inputElement->getPos()){ case UP: inputContainerLayout->addWidget(inputLabel,0,0); inputContainerLayout->addWidget(inputText,1,0); break; case DOWN: inputContainerLayout->addWidget(inputLabel,1,0); inputContainerLayout->addWidget(inputText,0,0); break; case LEFT: inputContainerLayout->addWidget(inputLabel,0,0); inputContainerLayout->addWidget(inputText,0,1); break; case RIGHT: inputContainerLayout->addWidget(inputLabel,0,1); inputContainerLayout->addWidget(inputText,0,0); break; default : break; } inputContainer->setLayout(inputContainerLayout); inputContainerLayout->setVerticalSpacing(1); mainLayout->addWidget(inputContainer); break; case IMAGE: /* TODO: Given an Image element, this part of the code should * renderize a box (as big as width and height attributes say) * containing the image. The base64 encoding of the image is given * by the content of the element. Probably the most part of the times * this functionality won't be required. The important thing to do * is to renderize a button to snap the photo. */ break; case RECORDING: /* TODO: * The stuff to do is exactly the same then the one of the image. The only * differenze is that you have to renderize a "record","play","pause" button * to interact with the mobile recorder. */ break; case SELECT: Select * selectElement = dynamic_cast<Select*>(currentElement); QButtonGroup * radioGroup = new QButtonGroup(); radioGroup->setExclusive(selectElement->isMutex()); for(int j = 0; j < selectElement->getOptions().size(); j++){ Select::Option optionElement = selectElement->getOption(j); QRadioButton * option = new QRadioButton(optionElement.getContent(), this); option->setChecked(optionElement.isSelected()); //The object name is eventually used to retrive the object reference //(During the saving process). //So the ID in the configuration file MUST be unique. option->setObjectName(optionElement.getId()); inputElements.push_back(option); radioGroup->addButton(option); mainLayout->addWidget(option); } break; default: //TODO: handle exception break; } } } this->setLayout(mainLayout); this->resize(400,600); }
TEST(ConsumerStateTable, multitable) { DBConnector db(TEST_VIEW, "localhost", 6379, 0); ConsumerStateTable *consumers[NUMBER_OF_THREADS]; thread *producerThreads[NUMBER_OF_THREADS]; KeyOpFieldsValuesTuple kco; Select cs; int numberOfKeysSet = 0; int numberOfKeyDeleted = 0; int ret = 0, i; clearDB(); cout << "Starting " << NUMBER_OF_THREADS*2 << " producers and consumers on redis, using single thread for consumers and thread per producer" << endl; /* Starting the consumer before the producer */ for (i = 0; i < NUMBER_OF_THREADS; i++) { consumers[i] = new ConsumerStateTable(&db, string("UT_REDIS_THREAD_") + to_string(i)); producerThreads[i] = new thread(producerWorker, i); } for (i = 0; i < NUMBER_OF_THREADS; i++) cs.addSelectable(consumers[i]); while (1) { Selectable *is; int fd; ret = cs.select(&is, &fd); EXPECT_EQ(ret, Select::OBJECT); ((ConsumerStateTable *)is)->pop(kco); if (kfvOp(kco) == "SET") { numberOfKeysSet++; validateFields(kfvKey(kco), kfvFieldsValues(kco)); } else if (kfvOp(kco) == "DEL") { numberOfKeyDeleted++; if ((numberOfKeyDeleted % 100) == 0) cout << "-" << flush; } if (numberOfKeyDeleted == NUMBER_OF_OPS * NUMBER_OF_THREADS) break; } EXPECT_TRUE(numberOfKeysSet <= numberOfKeyDeleted); /* Making sure threads stops execution */ for (i = 0; i < NUMBER_OF_THREADS; i++) { producerThreads[i]->join(); delete consumers[i]; delete producerThreads[i]; } cout << endl << "Done." << endl; }
TEST(ConsumerStateTable, double_set) { clearDB(); /* Prepare producer */ int index = 0; string tableName = "UT_REDIS_THREAD_" + to_string(index); DBConnector db(TEST_VIEW, "localhost", 6379, 0); ProducerStateTable p(&db, tableName); string key = "TheKey"; int maxNumOfFields = 2; /* First set operation */ { vector<FieldValueTuple> fields; for (int j = 0; j < maxNumOfFields; j++) { FieldValueTuple t(field(j), value(j)); fields.push_back(t); } p.set(key, fields); } /* Second set operation */ { vector<FieldValueTuple> fields; for (int j = 0; j < maxNumOfFields * 2; j += 2) { FieldValueTuple t(field(j), value(j)); fields.push_back(t); } p.set(key, fields); } /* Prepare consumer */ ConsumerStateTable c(&db, tableName); Select cs; Selectable *selectcs; cs.addSelectable(&c); int tmpfd; /* First pop operation */ { int ret = cs.select(&selectcs, &tmpfd); EXPECT_TRUE(ret == Select::OBJECT); KeyOpFieldsValuesTuple kco; c.pop(kco); EXPECT_TRUE(kfvKey(kco) == key); EXPECT_TRUE(kfvOp(kco) == "SET"); auto fvs = kfvFieldsValues(kco); EXPECT_EQ(fvs.size(), (unsigned int)(maxNumOfFields + maxNumOfFields/2)); map<string, string> mm; for (auto fv: fvs) { mm[fvField(fv)] = fvValue(fv); } for (int j = 0; j < maxNumOfFields; j++) { EXPECT_EQ(mm[field(j)], value(j)); } for (int j = 0; j < maxNumOfFields * 2; j += 2) { EXPECT_EQ(mm[field(j)], value(j)); } } /* Second select operation */ { int ret = cs.select(&selectcs, &tmpfd, 1000); EXPECT_TRUE(ret == Select::TIMEOUT); } }
void MainWindow::selectRS() { if(!model) return; SelectDialog *dial = new SelectDialog; QString str = ""; if( dial->exec() == QDialog::Accepted ) { if( !dial->getShowAll() ) { str = "Birth >= '"; str += dial->getFromDate().toString("yyyy-MM-dd"); str += "'"; str += " AND "; str += " Birth <= '"; str += dial->getToDate().toString("yyyy-MM-dd"); str += "'"; } QThread *thread = new QThread; Select *sel = new Select; sel->setModel(model); sel->setStr(str); sel->moveToThread(thread); QObject::connect( thread, SIGNAL( started() ), sel, SLOT( process() ) ); QObject::connect( sel, SIGNAL( finished() ), thread, SLOT( quit() ) ); QObject::connect( sel, SIGNAL( finished() ), sel, SLOT( deleteLater() ) ); QObject::connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) ); thread->start(); } delete dial; /*QThread *thread = new QThread; Select *sel = new Select; sel->setModel(model); sel->setStr(str); sel->moveToThread(thread); QObject::connect( thread, SIGNAL( started() ), sel, SLOT( process() ) ); QObject::connect( sel, SIGNAL( finished() ), thread, SLOT( quit() ) ); QObject::connect( sel, SIGNAL( finished() ), sel, SLOT( deleteLater() ) ); QObject::connect( thread, SIGNAL( finished() ), thread, SLOT( deleteLater() ) ); thread->start();*/ /*SelectDialog *dial = new SelectDialog; if( dial->exec() == QDialog::Accepted ) { if( dial->getShowAll() ) model->setFilter(""); else { QString str; str = "Birth >= '"; str += dial->getFromDate().toString("yyyy-MM-dd"); str += "'"; str += " AND "; str += " Birth <= '"; str += dial->getToDate().toString("yyyy-MM-dd"); str += "'"; model->setFilter(str); } model->select(); } delete dial;*/ }
/** accepts and keeps track of connections. reads data from connected peers and notifies through virtual methods if packets can be deserialized \param tls use GnuTLS for encryption \param port listen for incoming connections at this port \param maxPeers maximum number of connected peers */ void serve(bool tls, int port, int maxPeers) { if (tls) sock.reset(new TLSSocket()); else sock.reset(new Socket()); sock->setNonBlocking(); sock->bind(port); sock->listen(maxPeers); Select select; /* Wait for a peer, send data and term */ while (!closed) { select.reset(); if (peers.size() < maxPeers) select.input(sock->getFd()); for (typename Peers::iterator i = peers.begin(); i != peers.end(); i++) { select.input((*i)->getFd()); } if (select.select(100) == -1) continue; if (select.canRead(sock->getFd()) && peers.size() < maxPeers) { try { Socket* csock = sock->accept(); if (tls) { boost::threadpool::schedule(pool, boost::bind(&Server::handshake, this, csock)); } else { peers.push_back(boost::shared_ptr<PeerT>(new PeerT())); csock->setNonBlocking(); peers.back()->setup(csock); onJoin(*peers.back()); } } catch (SocketExcept& e) { std::cerr << e.what() << std::endl; } } if (tls) { Socket* sock = NULL; socketsReady.try_pop_front(sock); if (sock) { sock->setNonBlocking(); peers.push_back(boost::shared_ptr<PeerT>(new PeerT())); peers.back()->setup(sock); onJoin(*peers.back()); } } for (size_t i = 0; i < peers.size(); i++) { boost::shared_ptr<PeerT>& p = peers[i]; if (select.canRead(p->getFd())) p->onInput(); while (p->hasPacket()) { onPacket(*p); } } // collect dead peers size_t count = peers.size(); for (size_t i = 0; i < count; ) { if (!peers[i]->isActive()) { onLeave(*peers[i]); peers[i] = peers[peers.size() - 1]; count--; } else i++; } if (count < peers.size()) { peers.resize(count); } } }
int KankerApp::createGui() { /* Main panel.*/ gui = new Panel(new RenderGL(), painter.height() - 20, GUI_STYLE_NONE); if (NULL == gui) { RX_ERROR("Cannot allocate the gui."); return -1; } gui->setPosition(painter.width() - (gui->w + 30), 8); gui->lockPosition(); /* Font options. */ Group* group_font = gui->addGroup("Font", GUI_STYLE_NONE); if (NULL == group_font) { RX_ERROR("Failed to allocate a new gui group."); return -2; } group_font->add(new Button("Add character to loaded font", 0, GUI_ICON_FONT, on_add_characters_clicked, this, GUI_STYLE_NONE)); group_font->add(new Button("Show test message", 0, GUI_ICON_FONT, on_font_test_clicked, this, GUI_STYLE_NONE)); group_font->add(new Button("Send test message to robot", 0, GUI_ICON_UPLOAD, on_abb_send_message_to_robot_clicked, this, GUI_STYLE_NONE)); group_font->add(new Button("Send test positions to robot", 0, GUI_ICON_UPLOAD, on_abb_send_test_clicked, this, GUI_STYLE_NONE)); group_font->add(new Button("Send SWIPE to robot", 0, GUI_ICON_UPLOAD, on_abb_send_swipe_clicked, this, GUI_STYLE_NONE)).setMarginBottom(10); /* Saving */ Group* group_save = gui->addGroup("Save font", GUI_STYLE_NONE); if (NULL == group_save) { RX_ERROR("Failed to allocate a new gui group"); return -3; } group_save->add(new Text("Filename", font_filename, 135)); group_save->add(new Button("Save", 0, GUI_ICON_FLOPPY_O, on_font_save_clicked, this, GUI_STYLE_NONE)).setMarginBottom(10); /* Loading */ { std::vector<std::string> fonts; if (0 == getFontFiles(fonts)) { Group* group_load = gui->addGroup("Load font", GUI_STYLE_NONE); if (NULL == group_load) { RX_ERROR("Failed to allocate the load gui group"); return -4; } Select* sel = new Select("Load file", 1, fonts, on_font_file_selected, this, GUI_STYLE_NONE); sel->setDirection(GUI_DIRECTION_UP); group_load->add(sel); group_load->add(new Button("Load", 0, GUI_ICON_FOLDER_OPEN, on_font_load_clicked, this, GUI_STYLE_NONE)).setMarginBottom(10); } } /* Abb settings. */ Group* group_abb = gui->addGroup("Abb", GUI_STYLE_NONE); if (NULL == group_abb) { RX_ERROR("Failed to allocate the abb gui group"); return -5; } group_abb->add(new Slider<float>("ABB.offset_x", kanker_abb.offset_x, -1300, 1300, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<float>("ABB.offset_y", kanker_abb.offset_y, -1300, 1300, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<float>("ABB.char_scale", kanker_abb.char_scale, 0, 1000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<float>("ABB.line_height", kanker_abb.line_height, 0, 1000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<float>("ABB.word_spacing", kanker_abb.word_spacing, 0, 1000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<int>("ABB.min_x", kanker_abb.min_x, -15000, 15000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<int>("ABB.max_x", kanker_abb.max_x, -15000, 15000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<int>("ABB.min_y", kanker_abb.min_y, -15000, 15000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<int>("ABB.max_y", kanker_abb.max_y, -15000, 15000, 1, GUI_STYLE_NONE)); group_abb->add(new Slider<float>("ABB.min_point_dist", kanker_abb.min_point_dist, 1.0, 50.0, 0.5, GUI_STYLE_NONE)).setMarginBottom(10); group_abb->add(new Text("ABB.host", kanker_abb.abb_host)); group_abb->add(new Slider<int>("ABB.port", kanker_abb.abb_port, 0, 999999, 1, GUI_STYLE_NONE)).setMarginBottom(10); group_abb->add(new Button("Save ABB Settings", 0, GUI_ICON_FLOPPY_O, on_abb_save_settings_clicked, this, GUI_STYLE_NONE)); group_abb->add(new Button("Load ABB Settings", 0, GUI_ICON_REFRESH, on_abb_load_settings_clicked, this, GUI_STYLE_NONE)); return 0; }
TEST(ConsumerStateTable, singlethread) { clearDB(); int index = 0; string tableName = "UT_REDIS_THREAD_" + to_string(index); DBConnector db(TEST_VIEW, "localhost", 6379, 0); ProducerStateTable p(&db, tableName); for (int i = 0; i < NUMBER_OF_OPS; i++) { vector<FieldValueTuple> fields; int maxNumOfFields = getMaxFields(i); for (int j = 0; j < maxNumOfFields; j++) { FieldValueTuple t(field(j), value(j)); fields.push_back(t); } if ((i % 100) == 0) cout << "+" << flush; p.set(key(i), fields); } ConsumerStateTable c(&db, tableName); Select cs; Selectable *selectcs; int tmpfd; int ret, i = 0; KeyOpFieldsValuesTuple kco; cs.addSelectable(&c); int numberOfKeysSet = 0; while ((ret = cs.select(&selectcs, &tmpfd)) == Select::OBJECT) { c.pop(kco); EXPECT_TRUE(kfvOp(kco) == "SET"); numberOfKeysSet++; validateFields(kfvKey(kco), kfvFieldsValues(kco)); if ((i++ % 100) == 0) cout << "-" << flush; if (numberOfKeysSet == NUMBER_OF_OPS) break; } for (i = 0; i < NUMBER_OF_OPS; i++) { p.del(key(i)); if ((i % 100) == 0) cout << "+" << flush; } int numberOfKeyDeleted = 0; while ((ret = cs.select(&selectcs, &tmpfd)) == Select::OBJECT) { c.pop(kco); EXPECT_TRUE(kfvOp(kco) == "DEL"); numberOfKeyDeleted++; if ((i++ % 100) == 0) cout << "-" << flush; if (numberOfKeyDeleted == NUMBER_OF_OPS) break; } EXPECT_TRUE(numberOfKeysSet <= numberOfKeyDeleted); EXPECT_EQ(ret, Selectable::DATA); cout << "Done. Waiting for all job to finish " << NUMBER_OF_OPS << " jobs." << endl; cout << endl << "Done." << endl; }