Closed kpu closed 3 years ago
You'll want to put pcqueue before workers because workers depend on queue being alive.
BatchTranslator
(workers_) contains std::thread
, which is only movable. Moving and rebuilding the graphs etc seems to be wasted computation. Is it okay keeping these as unique_ptr
s?j
Why can't you just reserve
and emplace_back
the std::vector<BatchTranslator>
?
My bad, kept trying to use move semantics, took looking at cppreference for emplace_back to figure I could pass args directly to be forwarded. Done in commit referenced.
The workers and the queue are properly owned by Service.
Currently they are shared pointers.
https://github.com/browsermt/mts/blob/41978b4c225138432883a8c1abc98e7a86a31c2c/src/bergamot/service.h#L27 https://github.com/browsermt/mts/blob/41978b4c225138432883a8c1abc98e7a86a31c2c/src/bergamot/service.h#L28
They should be member variables of Service. Remove the shared pointer. If Service launches threads it's also responsible for cleaning them up in its destruction. And order the member variables such that the threads are stopped before the queue is deallocated.