本文整理汇总了C++中Pool类的典型用法代码示例。如果您正苦于以下问题:C++ Pool类的具体用法?C++ Pool怎么用?C++ Pool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Java_org_voltdb_jni_ExecutionEngine_nativeUpdateHashinator
/*
* Class: org_voltdb_jni_ExecutionEngine
* Method: nativeUpdateHashinator
* Signature: (JI)I
*/
SHAREDLIB_JNIEXPORT void JNICALL Java_org_voltdb_jni_ExecutionEngine_nativeUpdateHashinator(JNIEnv *env, jobject obj, jlong engine_ptr)
{
VOLT_DEBUG("nativeUpdateHashinator in C++ called");
VoltDBEngine *engine = castToEngine(engine_ptr);
assert(engine);
Topend *topend = static_cast<JNITopend*>(engine->getTopend())->updateJNIEnv(env);
try {
updateJNILogProxy(engine); //JNIEnv pointer can change between calls, must be updated
NValueArray& params = engine->getParameterContainer();
Pool *stringPool = engine->getStringPool();
deserializeParameterSet(engine->getParameterBuffer(), engine->getParameterBufferCapacity(), params, engine->getStringPool());
HashinatorType hashinatorType = static_cast<HashinatorType>(voltdb::ValuePeeker::peekAsInteger(params[0]));
const char *configValue = static_cast<const char*>(voltdb::ValuePeeker::peekObjectValue(params[1]));
engine->updateHashinator(hashinatorType, configValue);
stringPool->purge();
} catch (const FatalException &e) {
topend->crashVoltDB(e);
}
}
示例2: PostProcess
// Add missing descriptors which are not computed yet, but will be for the
// final release or during the 1.x cycle. However, the schema need to be
// complete before that, so just put default values for these.
// Also make sure that some descriptors that might have fucked up come out nice.
void PostProcess(Pool& pool, const Pool& options, const string& nspace) {
if (options.value<Real>("rhythm.compute") != 0) {
string rhythmspace = "rhythm.";
if (!nspace.empty()) rhythmspace = nspace + ".rhythm.";
const vector<string>& descNames = pool.descriptorNames();
if (find(descNames.begin(), descNames.end(), rhythmspace + "bpm_confidence") == descNames.end())
pool.set(rhythmspace + "bpm_confidence", 0.0);
if (find(descNames.begin(), descNames.end(), rhythmspace + "perceptual_tempo") == descNames.end())
pool.set(rhythmspace + "perceptual_tempo", "unknown");
if (find(descNames.begin(), descNames.end(), rhythmspace + "beats_loudness") == descNames.end())
pool.add(rhythmspace + "beats_loudness", Real(0.0));
if (find(descNames.begin(), descNames.end(), rhythmspace + "beats_loudness_band_ratio") == descNames.end())
pool.add(rhythmspace + "beats_loudness_band_Ratio", vector<Real>());
//if (find(descNames.begin(), descNames.end(), rhythmspace + "rubato_start") == descNames.end())
// pool.set(rhythmspace + "rubato_start", vector<Real>(0));
//if (find(descNames.begin(), descNames.end(), rhythmspace + "rubato_stop") == descNames.end())
// pool.set(rhythmspace + "rubato_stop", vector<Real>(0));
}
}
示例3: computeMidLevel
void computeMidLevel(const string& audioFilename, Real startTime, Real endTime, Pool& pool, const Pool& options, const string& nspace) {
/*************************************************************************
* 3rd pass: HPCP & beats loudness (depend on some descriptors that *
* have been computed during the 2nd pass) *
*************************************************************************/
Real replayGain = 0;
Real analysisSampleRate = options.value<Real>("analysisSampleRate");
const vector<string>& desc = pool.descriptorNames();
if (find(desc.begin(), desc.end(), "replayGain") != desc.end()) {
replayGain = pool.value<Real>("metadata.audio_properties.replay_gain");
}
string downmix = "mix";
try {
downmix = pool.value<string>("metadata.audio_properties.downmix");
}
catch (const EssentiaException&) {
throw EssentiaException("StreamingExtractor::computeLowLevel, could not determine downmix type");
}
streaming::AlgorithmFactory& factory = streaming::AlgorithmFactory::instance();
Algorithm* audio_3 = factory.create("EqloudLoader",
"filename", audioFilename,
"sampleRate", analysisSampleRate,
"startTime", startTime,
"endTime", endTime,
"replayGain", replayGain,
"downmix", downmix);
SourceBase& audioSource_2 = audio_3->output("audio");
// Compute Tonal descriptors (needed TuningFrequency before)
TonalDescriptors(audioSource_2, pool, options, nspace);
// Compute the loudness at the beats position (needed beats position)
string rhythmspace = "rhythm.";
if (!nspace.empty()) rhythmspace = nspace + ".rhythm.";
vector<Real> ticks = pool.value<vector<Real> >(rhythmspace + "beats_position");
Algorithm* beatsLoudness = factory.create("BeatsLoudness",
"sampleRate", analysisSampleRate,
"beats", ticks);
connect(audioSource_2, beatsLoudness->input("signal"));
connect(beatsLoudness->output("loudness"), pool, rhythmspace + "beats_loudness");
connect(beatsLoudness->output("loudnessBandRatio"), pool, rhythmspace + "beats_loudness_band_ratio");
cout << "Process step 3: Mid Level" << endl;
Network network(audio_3);
network.run();
}
示例4: SVN_JNI_NULL_PTR_EX
void SVNAdmin::deltify(const char *path, Revision &revStart, Revision &revEnd)
{
Pool requestPool;
SVN_JNI_NULL_PTR_EX(path, "path", );
path = svn_path_internal_style(path, requestPool.pool());
svn_repos_t *repos;
svn_fs_t *fs;
svn_revnum_t start = SVN_INVALID_REVNUM, end = SVN_INVALID_REVNUM;
svn_revnum_t youngest, revision;
Pool revisionPool;
SVN_JNI_ERR(svn_repos_open(&repos, path, requestPool.pool()), );
fs = svn_repos_fs (repos);
SVN_JNI_ERR(svn_fs_youngest_rev(&youngest, fs, requestPool.pool()), );
if (revStart.revision()->kind == svn_opt_revision_number)
/* ### We only handle revision numbers right now, not dates. */
start = revStart.revision()->value.number;
else if (revStart.revision()->kind == svn_opt_revision_head)
start = youngest;
else
start = SVN_INVALID_REVNUM;
if (revEnd.revision()->kind == svn_opt_revision_number)
end = revEnd.revision()->value.number;
else if (revEnd.revision()->kind == svn_opt_revision_head)
end = youngest;
else
end = SVN_INVALID_REVNUM;
/* Fill in implied revisions if necessary. */
if (start == SVN_INVALID_REVNUM)
start = youngest;
if (end == SVN_INVALID_REVNUM)
end = start;
if (start > end)
{
SVN_JNI_ERR(svn_error_create
(SVN_ERR_CL_ARG_PARSING_ERROR, NULL,
_("First revision cannot be higher than second")), );
}
示例5:
void
Path::init(const char * path)
{
Pool pool;
m_pathIsUrl = false;
if (path == 0)
m_path = "";
else
{
const char * int_path =
svn_path_internal_style(path, pool.pool());
m_path = int_path;
if (svn::Url::isValid(int_path))
m_pathIsUrl = true;
}
}
示例6: Java_org_voltdb_jni_ExecutionEngine_nativeHashinate
/*
* Class: org_voltdb_jni_ExecutionEngine
* Method: nativeHashinate
* Signature: (JI)I
*/
SHAREDLIB_JNIEXPORT jint JNICALL Java_org_voltdb_jni_ExecutionEngine_nativeHashinate(JNIEnv *env, jobject obj, jlong engine_ptr, jint partitionCount)
{
VOLT_DEBUG("nativeHashinate in C++ called");
VoltDBEngine *engine = castToEngine(engine_ptr);
assert(engine);
try {
updateJNILogProxy(engine); //JNIEnv pointer can change between calls, must be updated
NValueArray& params = engine->getParameterContainer();
Pool *stringPool = engine->getStringPool();
deserializeParameterSet(engine->getParameterBuffer(), engine->getParameterBufferCapacity(), params, engine->getStringPool());
int retval =
voltdb::TheHashinator::hashinate(params[0], partitionCount);
stringPool->purge();
return retval;
} catch (FatalException e) {
std::cout << "HASHINATE ERROR: " << e.m_reason << std::endl;
return org_voltdb_jni_ExecutionEngine_ERRORCODE_ERROR;
}
return org_voltdb_jni_ExecutionEngine_ERRORCODE_ERROR;
}
示例7: TRACE_POINT
OXT_FORCE_INLINE void
Group::onSessionInitiateFailure(Process *process, Session *session) {
boost::container::vector<Callback> actions;
TRACE_POINT();
// Standard resource management boilerplate stuff...
Pool *pool = getPool();
boost::unique_lock<boost::mutex> lock(pool->syncher);
assert(process->isAlive());
assert(isAlive() || getLifeStatus() == SHUTTING_DOWN);
UPDATE_TRACE_POINT();
P_DEBUG("Could not initiate a session with process " <<
process->inspect() << ", detaching from pool if possible");
if (!pool->detachProcessUnlocked(process->shared_from_this(), actions)) {
P_DEBUG("Process was already detached");
}
pool->fullVerifyInvariants();
lock.unlock();
runAllActions(actions);
}
示例8: typeid
void EntityManager::Dump()
{
Logger::Info("============================");
Logger::Info("EntityManager dump");
Logger::Info("============================");
Logger::Info("Pools:");
Logger::Info("============================");
Map<const char *, Pool *>::iterator poolIterator;
for(poolIterator = pools.begin(); poolIterator != pools.end(); ++poolIterator)
{
const char * poolName = poolIterator->first;
Pool * pool = poolIterator->second;
Logger::Info("Pool \"%s\" of type %s", poolName, typeid(*pool).name());
Logger::Info("----------------------------");
while(pool)
{
int32 count = pool->GetCount();
int32 maxCount = pool->GetMaxCount();
Logger::Info(" subpool of family %lld (%d elements, %d maxCount, %d bytes)", pool->GetEntityFamily()->family.GetBit(), count, maxCount, maxCount*pool->typeSizeof);
for(int32 i = 0; i < count; ++i)
{
pool->DumpElement(i);
}
pool = pool->GetNext();
Logger::Info(" ----------------------------");
}
}
}
示例9: bytePoolFree
void bytePoolFree( eBytePool bytePool, u8* data )
{
switch( bytePool )
{
case eBytePool0:
{
break;
}
case eBytePool32:
{
_bytePool32.Delete( ( Bx32* )data );
break;
}
case eBytePool128:
{
_bytePool128.Delete( ( Bx128* )data );
break;
}
case eBytePool512:
{
_bytePool512.Delete( ( Bx512* )data );
break;
}
case eBytePool2048:
{
_bytePool2048.Delete( ( Bx2048* )data );
break;
}
case eBytePool8192:
{
_bytePool8192.Delete( ( Bx8192* )data );
break;
}
case eBytePool16384:
{
_bytePool16384.Delete( ( Bx16384* )data );
break;
}
case eBytePool32768:
{
_bytePool32768.Delete( ( Bx32768* )data );
break;
}
case eBytePool65534:
{
_bytePool65534.Delete( ( Bx65534* )data );
break;
}
}
}
示例10: PostProcess
// Add missing descriptors which are not computed yet, but will be for the
// final release or during the 1.x cycle. However, the schema need to be
// complete before that, so just put default values for these.
// Also make sure that some descriptors that might have fucked up come out nice.
void PostProcess(Pool& pool, const string& nspace) {
string rhythmspace = "rhythm.";
if (!nspace.empty()) rhythmspace = nspace + ".rhythm.";
pool.set(rhythmspace + "bpm_confidence", 0.0);
pool.set(rhythmspace + "perceptual_tempo", "unknown");
try {
pool.value<vector<Real> >(rhythmspace + "beats_loudness");
}
catch (EssentiaException&) {
pool.set(rhythmspace + "beats_loudness", 0.0);
pool.set(rhythmspace + "beats_loudness_bass", 0.0);
}
try {
pool.value<vector<Real> >(rhythmspace + "rubato_start");
}
catch (EssentiaException&) {
pool.set(rhythmspace + "rubato_start", vector<Real>(0));
}
try {
pool.value<vector<Real> >(rhythmspace + "rubato_stop");
}
catch (EssentiaException&) {
pool.set(rhythmspace + "rubato_stop", vector<Real>(0));
}
// PCA analysis of spectral contrast output:
PCA(pool, nspace);
}
示例11:
Pool * EntityManager::CreatePool(const char * dataName, int32 maxSize)
{
Pool * pool = 0;
Map<const char *, Pool *>::iterator poolsIt = poolAllocators.find(dataName);
if (poolsIt != poolAllocators.end())
{
Pool * newPool = poolsIt->second->CreateCopy(maxSize);
Pool * prevPool = 0;
Map<const char *, Pool*>::iterator find = pools.find(dataName);
if(pools.end() != find)
{
prevPool = find->second;
}
newPool->SetNext(prevPool);
pools[dataName] = newPool;
pool = newPool;
}
return pool;
}
示例12: insertTuple
bool StreamedTable::insertTuple(TableTuple &source)
{
size_t mark = 0;
if (m_wrapper) {
mark = m_wrapper->appendTuple(m_executorContext->m_lastCommittedTxnId,
m_executorContext->currentTxnId(),
m_sequenceNo++,
m_executorContext->currentTxnTimestamp(),
source,
TupleStreamWrapper::INSERT);
m_tupleCount++;
m_usedTupleCount++;
UndoQuantum *uq = m_executorContext->getCurrentUndoQuantum();
Pool *pool = uq->getDataPool();
StreamedTableUndoAction *ua =
new (pool->allocate(sizeof(StreamedTableUndoAction)))
StreamedTableUndoAction(this, mark);
uq->registerUndoAction(ua);
}
return true;
}
示例13: PoolFix
Res PoolFix(Pool pool, ScanState ss, Seg seg, Addr *refIO)
{
AVERT_CRITICAL(Pool, pool);
AVERT_CRITICAL(ScanState, ss);
AVERT_CRITICAL(Seg, seg);
AVER_CRITICAL(pool == SegPool(seg));
AVER_CRITICAL(refIO != NULL);
/* Should only be fixing references to white segments. */
AVER_CRITICAL(TraceSetInter(SegWhite(seg), ss->traces) != TraceSetEMPTY);
return pool->fix(pool, ss, seg, refIO);
}
示例14: LevelAverage
void LevelAverage(Pool& pool, const string& nspace) {
// namespace:
string llspace = "lowlevel.";
if (!nspace.empty()) llspace = nspace + ".lowlevel.";
vector<Real> levelArray = pool.value<vector<Real> >(llspace + "loudness");
pool.remove(llspace + "loudness");
// Maximum dynamic
Real EPSILON = 10e-5;
Real maxValue = levelArray[argmax(levelArray)];
if (maxValue <= EPSILON) {
maxValue = EPSILON;
}
// Normalization to the maximum
Real THRESHOLD = 0.0001; // this corresponds to -80dB
for (uint i=0; i<levelArray.size(); i++) {
levelArray[i] /= maxValue;
if (levelArray[i] <= THRESHOLD) {
levelArray[i] = THRESHOLD;
}
}
// Average Level
Real levelAverage = 10*log10(mean(levelArray));
// Re-scaling and range-control
// This yields in numbers between
// 0 for signals with large dynamic variace and thus low dynamic average
// 1 for signal with little dynamic range and thus
// a dynamic average close to the maximum
Real x1 = -5.0;
Real x2 = -2.0;
Real levelAverageSqueezed = squeezeRange(levelAverage, x1, x2);
pool.set(llspace + "average_loudness", levelAverageSqueezed);
}
示例15: TEST
TEST(move, DISABLED_there_should_be_only_one_owner)
{
class Resource {
public:
Resource(std::string id)
: id(std::move(id))
{}
std::string id;
};
class Pool {
public:
Pool()
: resources{ {Resource{"one"}, Resource{"two"}} }
{}
size_t size() const {
return resources.size();
}
Resource borrow() {
return Resource{ "?" };
}
void return_(Resource) {}
bool contains(const std::string &id) const
{
return std::any_of(begin(resources), end(resources),
[&](const auto &resource) { return resource.id == id; });
}
private:
std::vector<Resource> resources;
};
Pool pool;
auto r1 = pool.borrow();
EXPECT_EQ("one", r1.id);
EXPECT_EQ(1u, pool.size());
EXPECT_FALSE(pool.contains("one"));
EXPECT_TRUE(pool.contains("two"));
pool.return_(r1);
EXPECT_EQ(2u, pool.size());
EXPECT_TRUE(pool.contains("one"));
EXPECT_TRUE(pool.contains("two"));
}