Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2013-03-12 15:18:24 -07:00
5 changed files with 16 additions and 7 deletions

View File

@@ -118,6 +118,14 @@ int JobQueue::getJobCount(JobType t)
return (c == mJobCounts.end()) ? 0 : c->second.first;
}
int JobQueue::getJobCountTotal(JobType t)
{
boost::mutex::scoped_lock sl(mJobLock);
std::map< JobType, std::pair<int, int> >::iterator c = mJobCounts.find(t);
return (c == mJobCounts.end()) ? 0 : (c->second.first + c->second.second);
}
int JobQueue::getJobCountGE(JobType t)
{ // return the number of jobs at this priority level or greater
int ret = 0;

View File

@@ -103,8 +103,9 @@ public:
void addJob(JobType type, const std::string& name, const boost::function<void(Job&)>& job);
int getJobCount(JobType t); // Jobs at this priority
int getJobCountGE(JobType t); // All jobs at or greater than this priority
int getJobCount(JobType t); // Jobs waiting at this priority
int getJobCountTotal(JobType t); // Jobs waiting plus running at this priority
int getJobCountGE(JobType t); // All waiting jobs at or greater than this priority
std::vector< std::pair<JobType, std::pair<int, int> > > getJobCounts(); // jobs waiting, threads doing
void shutdown();

View File

@@ -512,7 +512,7 @@ void Ledger::saveAcceptedLedger(Job&, bool fromConsensus)
if (!fromConsensus)
dropCache();
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) == 0)
if (theApp->getJobQueue().getJobCountTotal(jtPUBOLDLEDGER) == 0)
theApp->getLedgerMaster().resumeAcquiring();
}

View File

@@ -388,7 +388,7 @@ void LedgerMaster::setFullLedger(Ledger::pointer ledger)
return;
}
if (theApp->getJobQueue().getJobCount(jtPUBOLDLEDGER) > 2)
if (theApp->getJobQueue().getJobCountTotal(jtPUBOLDLEDGER) > 1)
{
cLog(lsDEBUG) << "Too many pending ledger saves";
return;

View File

@@ -212,12 +212,12 @@ private:
typedef websocketpp::processor::hybi_util::masking_key_type masking_key_type;
friend void intrusive_ptr_add_ref(const data * s) {
boost::unique_lock<boost::mutex> lock(s->m_lock);
boost::unique_lock<boost::recursive_mutex> lock(s->m_lock);
++s->m_ref_count;
}
friend void intrusive_ptr_release(const data * s) {
boost::unique_lock<boost::mutex> lock(s->m_lock);
boost::unique_lock<boost::recursive_mutex> lock(s->m_lock);
// TODO: thread safety
long count = --s->m_ref_count;
@@ -259,7 +259,7 @@ private:
mutable boost::detail::atomic_count m_ref_count;
mutable pool_weak_ptr m_pool;
mutable bool m_live;
mutable boost::mutex m_lock;
mutable boost::recursive_mutex m_lock;
};
typedef boost::intrusive_ptr<data> data_ptr;