void toResultLock::query(const QString &sql, const toQueryParams ¶m) { if (!handled()) return ; if (!setSqlAndParams(sql, param)) return ; if (Query) { delete Query; Query = NULL; } clear(); Checked.clear(); try { LastItem = NULL; if (!sql.isEmpty()) { Query = new toEventQuery(this, connection(), toSQL::string(SQLLock, connection()), toQueryParams() << sql, toEventQuery::READ_ALL); } else { Query = new toEventQuery(this, connection(), toSQL::string(SQLBlockingLock, connection()), toQueryParams(), toEventQuery::READ_ALL); } startQuery(); } TOCATCH } // query
void toResultItem::query(const QString &sql, toQueryParams const& param) { if (!setSqlAndParams(sql, param)) return ; start(); if (!handled() || Query) { if (!Query) done(); return ; } try { if (Query) { delete Query; Query = NULL; } Query = new toEventQuery(this , connection() , sql , param , toEventQuery::READ_ALL); connect(Query, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotPoll())); connect(Query, SIGNAL(done(toEventQuery*)), this, SLOT(slotQueryDone())); Query->start(); } catch (const QString &str) { done(); Utils::toStatusMessage(str); } }
boost::uint64_t wait( std::vector<unique_future<T1> > const& lazy_values , boost::int32_t suspend_for = 10 ) { boost::dynamic_bitset<> handled(lazy_values.size()); boost::uint64_t handled_count = 0; while (handled_count < lazy_values.size()) { bool suspended = false; for (boost::uint64_t i = 0; i < lazy_values.size(); ++i) { // loop over all lazy_values, executing the next as soon as its // value gets available if (!handled[i] && lazy_values[i].is_ready()) { handled[i] = true; ++handled_count; // give thread-manager a chance to look for more work while // waiting suspend(); suspended = true; } } // suspend after one full loop over all values, 10ms should be fine // (default parameter) if (!suspended) suspend(milliseconds(suspend_for)); } return handled.count(); }
void toResultStorage::query(void) { if (!handled() || Tablespaces || Files) return ; try { saveSelected(); clear(); toConnection &conn = connection(); toQList args; toPush(args, toQValue(toSizeDecode(Unit))); TablespaceValues.clear(); FileValues.clear(); Tablespaces = new toNoBlockQuery(conn, toQuery::Background, toSQL::string(ShowCoalesced ? SQLShowCoalesced : SQLNoShowCoalesced, connection()), args); Files = NULL; Files = new toNoBlockQuery(conn, toQuery::Background, toSQL::string(SQLDatafile, connection()), args); Poll.start(100); } TOCATCH }
void toResultExtent::query(const QString &sql, const toQList ¶ms) { try { if (!handled()) return ; if (!setSQLParams(sql, params)) return ; toQList::const_iterator i = params.begin(); if (i == params.end()) return ; QString owner = (*i); i++; if (i == params.end()) return ; QString table = (*i); List->changeParams(owner, table); toQList res = toQuery::readQueryNull(connection(), SQLTableTablespace, owner, table); Graph->setTablespace(toShift(res)); Graph->highlight(owner, table, QString::null); } TOCATCH }
inline std::size_t wait (std::vector<lcos::dataflow_base<T1, TR1> > const& dataflows, F const& f, boost::int64_t suspend_for = 10) { boost::dynamic_bitset<> handled(dataflows.size()); std::size_t handled_count = 0; std::vector<lcos::future<T1, TR1> > lazy_values; lazy_values.reserve(dataflows.size()); typedef dataflow_base<T1, TR1> dataflow_type; BOOST_FOREACH(dataflow_type const & d, dataflows) { lazy_values.push_back(d.get_future()); }
void toResultLine::query(const QString &sql, const toQueryParams ¶m, bool first) { if (!handled() || Query) return ; #if 0 start(); #endif setSqlAndParams(sql, param); try { First = first; Query = new toEventQuery(this, connection(), sql, param, toEventQuery::READ_ALL); connect(Query, SIGNAL(dataAvailable()), this, SLOT(poll())); connect(Query, SIGNAL(done()), this, SLOT(queryDone())); Query->start(); } TOCATCH }
void process_requests() { auto r = receive( // Handle no more than 5 requests at once. // No wait if queue is empty. from( m_chain ).handle_n( 5 ).no_wait_on_empty(), []( const request & req ) { // Imitation of some hardwork before sending a reply back. std::this_thread::sleep_for( random_pause() ); so_5::send< reply >( req.m_who, req.m_payload + "#handled" ); } ); m_logger_mbox <<= msg_maker() << "=== " << r.handled() << " request(s) handled"; if( !m_chain->empty() ) // Not all messages from chain have been processed. // Initiate new processing by sending the signal to itself. so_5::send< chain_has_requests >( *this ); }
void toResultStorage::query(const QString &sql, toQueryParams const& param) { Q_UNUSED(sql); Q_UNUSED(param); if (!handled() || Tablespaces || Files) return ; try { saveSelected(); clear(); toConnection &conn = connection(); toQueryParams args; args << toQValue(Utils::toSizeDecode(Unit)); TablespaceValues.clear(); FileValues.clear(); Tablespaces = new toEventQuery(this , conn , toSQL::string(ShowCoalesced ? SQLShowCoalesced : SQLNoShowCoalesced, connection()) , args , toEventQuery::READ_ALL); connect(Tablespaces, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotPollTablespaces())); connect(Tablespaces, SIGNAL(done(toEventQuery*)), this, SLOT(slotDoneTablespaces())); Tablespaces->start(); Files = new toEventQuery(this , conn , toSQL::string(SQLDatafile, connection()) , args , toEventQuery::READ_ALL); connect(Files, SIGNAL(dataAvailable(toEventQuery*)), this, SLOT(slotPollFiles())); connect(Files, SIGNAL(done(toEventQuery*)), this, SLOT(slotDoneFiles())); Files->start(); } TOCATCH }