thread_creator.cpp 949 B

123456789101112131415161718192021222324252627282930
  1. #include "thread_creator.h"
  2. #include "thread.h"
  3. TOwningThreadedLogBackendCreator::TOwningThreadedLogBackendCreator(THolder<ILogBackendCreator>&& slave)
  4. : Slave(std::move(slave))
  5. {}
  6. THolder<TLogBackend> TOwningThreadedLogBackendCreator::DoCreateLogBackend() const {
  7. return MakeHolder<TOwningThreadedLogBackend>(Slave->CreateLogBackend().Release(), QueueLen, QueueOverflowCallback);
  8. }
  9. bool TOwningThreadedLogBackendCreator::Init(const IInitContext& ctx) {
  10. ctx.GetValue("QueueLen", QueueLen);
  11. return Slave->Init(ctx);
  12. }
  13. void TOwningThreadedLogBackendCreator::ToJson(NJson::TJsonValue& value) const {
  14. value["QueueLen"] = QueueLen;
  15. value["Threaded"] = true;
  16. Slave->ToJson(value);
  17. }
  18. void TOwningThreadedLogBackendCreator::SetQueueOverflowCallback(std::function<void()> callback) {
  19. QueueOverflowCallback = std::move(callback);
  20. }
  21. void TOwningThreadedLogBackendCreator::SetQueueLen(size_t len) {
  22. QueueLen = len;
  23. }