本文整理汇总了C++中AutoArray::add方法的典型用法代码示例。如果您正苦于以下问题:C++ AutoArray::add方法的具体用法?C++ AutoArray::add怎么用?C++ AutoArray::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoArray
的用法示例。
在下文中一共展示了AutoArray::add方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: workerProc
void LinuxNetworkEventListener::workerProc() {
while (!Thread::canFinish()) {
try {
PollBase::Result res;
PollBase::WaitStatus wt = fdSelect.wait(nil, res);
if (wt == PollBase::waitWakeUp) {
while (pumpMessage());
} else {
AutoArray<std::pair<ISleepingObject *, natural>,SmallAlloc<32> > tocall;
SysTime tm = SysTime::now();
FdData *listeners = reinterpret_cast<FdData *>(res.userData);
for (ListenerMap::Iterator iter = listeners->listeners.getFwIter(); iter.hasItems();) {
const FdListener &l = iter.peek();
if (res.flags & l.waitMask) {
tocall.add(std::make_pair(l.notify,res.flags & l.waitMask));
listeners->listeners.erase(iter);
// l.notify->wakeUp(con.waitMask & l.waitMask);
} else if (l.waitTimeout.expired(tm)) {
tocall.add(std::make_pair(l.notify,0));
listeners->listeners.erase(iter);
// l.notify->wakeUp(0);
} else {
iter.skip();
}
}
updateFdData(listeners,res.fd);
for (natural i = 0; i < tocall.length(); i++) {
tocall[i].first->wakeUp(tocall[i].second);
}
}
} catch (const Exception &e) {
AppBase::current().onThreadException(e);
} catch (const std::exception &e) {
AppBase::current().onThreadException(StdException(THISLOCATION,e));
} catch (...) {
AppBase::current().onThreadException(UnknownException(THISLOCATION));
}
}
fdSelect.cancelAll(CleanUpProc(this));
/* fdSelect.dropAll();
while (fdSelect.hasItems()) {
const LinuxFdSelect::FdInfo &con = fdSelect.getNext();
FdData *listeners = reinterpret_cast<FdData *>(con.data);
if (listeners) delete listeners;
fdSelect.unset(con.fd);
}
*/
}
示例2: runReduce
ConstValue LocalView::runReduce(const ConstValue &rows) const {
AutoArray<KeyAndDocId, SmallAlloc<256> > keylist;
AutoArray<ConstValue, SmallAlloc<256> > values;
keylist.reserve(rows.length());
values.reserve(rows.length());
for (JSON::ConstIterator iter = rows->getFwConstIter(); iter.hasItems();) {
const JSON::ConstValue &v = iter.getNext();
keylist.add(KeyAndDocId(v["key"],v["id"].getStringA()));
values.add(v["value"]);
}
return reduce(keylist,values,false);
}
示例3: couchLoadData
static void couchLoadData(PrintTextA &print) {
CouchDB db(getTestCouch());
db.use(DATABASENAME);
AutoArray<Document, SmallAlloc<50> > savedDocs;
Changeset chset(db.createChangeset());
natural id=10000;
JSON::Value data = db.json.factory->fromString(strdata);
for (JSON::Iterator iter = data->getFwIter(); iter.hasItems();) {
const JSON::KeyValue &kv= iter.getNext();
Document doc;
doc.edit(db.json)
("name",kv[0])
("age",kv[1])
("height",kv[2])
("_id",ToString<natural>(id,16));
id+=14823;
savedDocs.add(doc);
chset.update(doc);
}
chset.commit(false);
Set<StringA> uuidmap;
for (natural i = 0; i < savedDocs.length(); i++) {
StringA uuid = savedDocs[i]["_id"]->getStringUtf8();
// print("%1\n") << uuid;
uuidmap.insert(uuid);
}
print("%1") << uuidmap.size();
}
示例4: dbOrderFromJSON
LightSpeed::StringA dbOrderFromJSON(const LightSpeed::JSON::INode &nd) {
using namespace LightSpeed;
AutoArray<char, SmallAlloc<256> > buff;
for (natural i = 0; i < nd.getEntryCount();i++) {
ConstStrA fld = nd[i].getStringUtf8();
if (fld.empty() || fld == ConstStrA('^') || fld.find('`') != naturalNull)
throw ErrorMessageException(THISLOCATION, "Unacceptable field name");
if (i) buff.append(ConstStrA(", "));
if (fld[0] == '^') {
buff.add('`');buff.append(fld.offset(1));buff.add('`');
buff.append(ConstStrA(" DESC"));
} else {
buff.add('`');buff.append(fld);buff.add('`');
buff.append(ConstStrA(" ASC"));
}
}
return ConstStrA(buff);
}
示例5: startApp
int LightSpeed::AppBase::main_entry( int argc, wchar_t *argv[], ConstStrW pathname)
{
AutoArray<ConstStrW> params;
params.reserve(argc);
for (int i = 0; i < argc; i++)
params.add(ConstStrW(argv[i]));
appPathname = pathname;
return startApp(Args(params));
}
示例6: processRequest
bool ServiceApp::processRequest(const void *request)
{
const char *p = reinterpret_cast<const char*>(request);
natural count = *p++;
ConstStrA command(p);
p += command.length() + 1;
AutoArray<String,StaticAlloc<256> > params;
AutoArray<ConstStrW,StaticAlloc<256> > wparams;
for(natural i = 0;i < count;i++){
ConstStrA param(p);
p += param.length() + 1;
params.add(String(param));
wparams.add(ConstStrW(params[i]));
}
AutoArray<byte> output;
output.resize(instance->getReplyMaxSize());
SeqOutputBuffer fakeout(output.data() + sizeof (integer), output.length() - sizeof (integer));
fakeout.setStaticObj();
integer res = -1;
bool stop = false;
SeqFileOutput out(&fakeout);
try {
res = onMessage(command, wparams, out);
stop = command == ConstStrA(stopCmd);
}
catch(std::exception & e){
TextOut<SeqFileOutput> msg(out);
msg("%1") << e.what();
res = -1;
}
try {
*reinterpret_cast<integer*>(output.data()) = res;
instance->sendReply(output.data(), fakeout.length() + sizeof (integer));
}
catch(...){
}
return !stop;
}