.. _program_listing_file_src_translator_service.h: Program Listing for File service.h ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/translator/service.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #ifndef SRC_BERGAMOT_SERVICE_H_ #define SRC_BERGAMOT_SERVICE_H_ #include "batch_translator.h" #include "data/types.h" #include "response.h" #include "response_builder.h" #include "text_processor.h" #include "threadsafe_batcher.h" #include "translator/parser.h" #include "vocabs.h" #ifndef WASM_COMPATIBLE_SOURCE #include #endif #include #include namespace marian { namespace bergamot { class Service { public: explicit Service(Ptr options, MemoryBundle memoryBundle = {}); explicit Service(const std::string &config, MemoryBundle memoryBundle = {}) : Service(parseOptions(config, /*validate=*/false), std::move(memoryBundle)) {} ~Service(); std::future translate(std::string &&source, ResponseOptions options = ResponseOptions()); std::vector translateMultiple(std::vector &&source, ResponseOptions responseOptions); bool isAlignmentSupported() const { return options_->hasAndNotEmpty("alignment"); } private: std::future queueRequest(std::string &&input, ResponseOptions responseOptions); void dispatchTranslate(); void blockIfWASM(); size_t numWorkers_; Ptr options_; AlignedMemory modelMemory_; // ORDER DEPENDENCY (translators_) AlignedMemory shortlistMemory_; // ORDER DEPENDENCY (translators_) size_t requestId_; Vocabs vocabs_; // ORDER DEPENDENCY (text_processor_) TextProcessor text_processor_; // ORDER DEPENDENCY (vocabs_) ThreadsafeBatcher batcher_; // The following constructs are available providing full capabilities on a non // WASM platform, where one does not have to hide threads. #ifdef WASM_COMPATIBLE_SOURCE BatchTranslator blocking_translator_; // ORDER DEPENDENCY (modelMemory_, shortlistMemory_) #else std::vector workers_; #endif // WASM_COMPATIBLE_SOURCE }; } // namespace bergamot } // namespace marian #endif // SRC_BERGAMOT_SERVICE_H_