// File: tdv[P]boss/boss/src/class_factory/class_factory.cpp
// Function: Boss::ClassFactory::Clean()
void ClassFactory::Clean()
  {
    while (IsRunCleaner)
    {
      try
      {
        std::this_thread::sleep_for(std::chrono::seconds(CleanerTimeout));
        if (!IsRunCleaner)
          break;
        
        std::lock_guard<std::recursive_mutex> Lock(Mtx);
        std::set<ServiceId> ServicesForUnload;
        for (auto const & i : Modules)
        {
          try
          {
            if (!i.second->GetModule().GetRefCount())
              ServicesForUnload.insert(i.first);
          }
          catch (std::exception const &)
          {
            // TODO :
          }
        }
        std::vector<ClassId> ClassIdsForDelete;
        for (auto const &i : Services)
        {
          if (ServicesForUnload.find(i.second) != std::end(ServicesForUnload))
            ClassIdsForDelete.push_back(i.first);
        }
        for (auto const &i : ServicesForUnload)
          Modules.erase(i);
        for (auto const &i : ClassIdsForDelete)
          Services.erase(i);
      }
      catch (...)
      {
      }
    }
  }

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movq %rdi, 0x150(%rsp)
movq 0x150(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movb 0xb8(%rax), %al
testb $0x1, %al
je 0x9476c
movq 0x38(%rsp), %rsi
addq $0xbc, %rsi
leaq 0x148(%rsp), %rdi
callq 0x8e0e0
jmp 0x9433a
leaq 0x148(%rsp), %rdi
callq 0x8cd60
jmp 0x94349
movq 0x38(%rsp), %rax
movb 0xb8(%rax), %al
testb $0x1, %al
jne 0x94376
jmp 0x9476c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x94755
movq 0x38(%rsp), %rsi
addq $0x20, %rsi
leaq 0x130(%rsp), %rdi
callq 0x8d2f0
jmp 0x9438e
leaq 0x100(%rsp), %rdi
callq 0x8f0e0
movq 0x38(%rsp), %rax
addq $0x80, %rax
movq %rax, 0xf8(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x8e780
movq %rax, 0xf0(%rsp)
movq 0xf8(%rsp), %rdi
callq 0x8d4d0
movq %rax, 0xe8(%rsp)
leaq 0xf0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x8fac0
testb $0x1, %al
jne 0x943f6
jmp 0x944f7
leaq 0xf0(%rsp), %rdi
callq 0x8f210
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
addq $0x8, %rdi
callq 0x8d050
movq %rax, %rdi
callq 0x8bc40
movq %rax, 0x30(%rsp)
jmp 0x9442b
movq 0x30(%rsp), %rdi
callq 0x8d3d0
movl %eax, 0x2c(%rsp)
jmp 0x9443b
movl 0x2c(%rsp), %eax
cmpl $0x0, %eax
jne 0x944dc
movq 0xe0(%rsp), %rsi
leaq 0x100(%rsp), %rdi
callq 0x8b300
movb %dl, 0x1f(%rsp)
movq %rax, 0x20(%rsp)
jmp 0x94468
movb 0x1f(%rsp), %al
movq 0x20(%rsp), %rcx
movq %rcx, 0xd0(%rsp)
movb %al, 0xd8(%rsp)
jmp 0x944dc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
movl 0x13c(%rsp), %eax
movl $0x2, %ecx
cmpl %ecx, %eax
jne 0x9473b
movq 0x140(%rsp), %rdi
callq 0x8b730
movq %rax, 0xc8(%rsp)
callq 0x8e640
jmp 0x944c6
jmp 0x944c8
jmp 0x944ca
leaq 0xf0(%rsp), %rdi
callq 0x8bfa0
jmp 0x943d8
jmp 0x944c8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
jmp 0x9473b
leaq 0xb0(%rsp), %rdi
callq 0x8f330
movq 0x38(%rsp), %rax
addq $0x48, %rax
movq %rax, 0xa8(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x8f630
movq %rax, 0xa0(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x8ddb0
movq %rax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x8d2a0
testb $0x1, %al
jne 0x9455d
jmp 0x9462e
leaq 0xa0(%rsp), %rdi
callq 0x8b210
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rsi
addq $0x4, %rsi
leaq 0x100(%rsp), %rdi
callq 0x8eb90
movq %rax, 0x10(%rsp)
jmp 0x94592
movq 0x10(%rsp), %rax
movq %rax, 0x88(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x8c370
movq %rax, 0x8(%rsp)
jmp 0x945b3
movq 0x8(%rsp), %rax
movq %rax, 0x80(%rsp)
leaq 0x88(%rsp), %rdi
leaq 0x80(%rsp), %rsi
callq 0x8b500
testb $0x1, %al
jne 0x945db
jmp 0x9461a
movq 0x90(%rsp), %rsi
leaq 0xb0(%rsp), %rdi
callq 0x8d830
jmp 0x945f2
jmp 0x9461a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x140(%rsp)
movl %eax, 0x13c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x8bf30
jmp 0x9473b
jmp 0x9461c
leaq 0xa0(%rsp), %rdi
callq 0x8bb80
jmp 0x9453f
leaq 0x100(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x8f750
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
callq 0x8bec0
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x8b500
testb $0x1, %al
jne 0x9466e
jmp 0x946a0
leaq 0x70(%rsp), %rdi
callq 0x8d040
movq 0x38(%rsp), %rdi
movq %rax, 0x60(%rsp)
subq $-0x80, %rdi
movq 0x60(%rsp), %rsi
callq 0x8f990
jmp 0x94692
jmp 0x94694
leaq 0x70(%rsp), %rdi
callq 0x8dff0
jmp 0x94659
leaq 0xb0(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x8cba0
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
callq 0x8da20
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x8daa0
testb $0x1, %al
jne 0x946e0
jmp 0x94712
leaq 0x50(%rsp), %rdi
callq 0x904a0
movq 0x38(%rsp), %rdi
movq %rax, 0x40(%rsp)
addq $0x48, %rdi
movq 0x40(%rsp), %rsi
callq 0x90610
jmp 0x94704
jmp 0x94706
leaq 0x50(%rsp), %rdi
callq 0x8fba0
jmp 0x946cb
leaq 0xb0(%rsp), %rdi
callq 0x8bf30
leaq 0x100(%rsp), %rdi
callq 0x8cf60
leaq 0x130(%rsp), %rdi
callq 0x90590
jmp 0x94767
leaq 0x100(%rsp), %rdi
callq 0x8cf60
leaq 0x130(%rsp), %rdi
callq 0x90590
movq 0x140(%rsp), %rdi
callq 0x8b730
callq 0x8e640
jmp 0x9430c
addq $0x158, %rsp            # imm = 0x158
retq
nopw %cs:(%rax,%rax)