mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-24 20:32:59 +03:00
New member function wait that won't return until sampling is done.
This commit is contained in:
parent
ac99ec519f
commit
69f15d0c5a
@ -1,3 +1,4 @@
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include "ug_bitext_pstats.h"
|
||||
|
||||
namespace Moses
|
||||
@ -65,7 +66,7 @@ namespace Moses
|
||||
|
||||
bool
|
||||
pstats::
|
||||
add(uint64_t pid, float const w,
|
||||
add(uint64_t pid, float const w, float const b,
|
||||
vector<uchar> const& a,
|
||||
uint32_t const cnt2,
|
||||
uint32_t fwd_o,
|
||||
@ -73,7 +74,7 @@ namespace Moses
|
||||
{
|
||||
boost::lock_guard<boost::mutex> guard(this->lock);
|
||||
jstats& entry = this->trg[pid];
|
||||
entry.add(w, a, cnt2, fwd_o, bwd_o, docid);
|
||||
entry.add(w, b, a, cnt2, fwd_o, bwd_o, docid);
|
||||
if (this->good < entry.rcnt())
|
||||
{
|
||||
UTIL_THROW(util::Exception, "more joint counts than good counts:"
|
||||
@ -82,5 +83,14 @@ namespace Moses
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
pstats::
|
||||
wait() const
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(this->lock);
|
||||
while (this->in_progress)
|
||||
this->ready.wait(lock);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ namespace Moses
|
||||
#if UG_BITEXT_TRACK_ACTIVE_THREADS
|
||||
static ThreadSafeCounter active;
|
||||
#endif
|
||||
boost::mutex lock; // for parallel gathering of stats
|
||||
boost::condition_variable ready; // consumers can wait for me to be ready
|
||||
mutable boost::mutex lock; // for parallel gathering of stats
|
||||
mutable boost::condition_variable ready; // consumers can wait for me to be ready
|
||||
|
||||
size_t raw_cnt; // (approximate) raw occurrence count
|
||||
size_t sample_cnt; // number of instances selected during sampling
|
||||
@ -46,6 +46,7 @@ namespace Moses
|
||||
bool
|
||||
add(uint64_t const pid, // target phrase id
|
||||
float const w, // sample weight (1./(# of phrases extractable))
|
||||
float const b, // sample bias score
|
||||
alnvec const& a, // local alignment
|
||||
uint32_t const cnt2, // raw target phrase count
|
||||
uint32_t fwd_o, // fwd. phrase orientation
|
||||
@ -57,6 +58,7 @@ namespace Moses
|
||||
size_t const num_pairs, // # of phrases extractable here
|
||||
int const po_fwd, // fwd phrase orientation
|
||||
int const po_bwd); // bwd phrase orientation
|
||||
void wait() const;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user