Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Translator.cpp « server « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3c0f4dc32074d7d1a2c5c2d516114d4ccb1b84c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// -*- mode: c++; indent-tabs-mode: nil; tab-width:2  -*-

#include "Translator.h"
#include "TranslationRequest.h"
#include "Server.h"

namespace MosesServer
{

using namespace std;
using namespace Moses;

Translator::
Translator(Server& server)
  : m_server(server),
    m_threadPool(server.options().numThreads)
{
  // signature and help strings are documentation -- the client
  // can query this information with a system.methodSignature and
  // system.methodHelp RPC.
  this->_signature = "S:S";
  this->_help = "Does translation";
}

void
Translator::
execute(xmlrpc_c::paramList const& paramList,
        xmlrpc_c::value *   const  retvalP)
{
  boost::condition_variable cond;
  boost::mutex mut;
  boost::shared_ptr<TranslationRequest> task;
  task = TranslationRequest::create(this, paramList,cond,mut);
  m_threadPool.Submit(task);
  boost::unique_lock<boost::mutex> lock(mut);
  while (!task->IsDone())
    cond.wait(lock);
  *retvalP = xmlrpc_c::value_struct(task->GetRetData());
}

Session const& 
Translator::
get_session(uint64_t const id)
{
  return m_server.get_session(id);
}

}