// File: /workspace/github_cpp_makefile_star2_O2/Barath-Kannan[P]SignalsAndSlots/test/SignalTest_Parametrized.cpp
// Function: SignalTestParametrized_LengthyUsage_Test::TestBody()
TEST_P(SignalTestParametrized, LengthyUsage) {
    auto func = ([this](sigType x) {
        std::this_thread::sleep_for(std::chrono::nanoseconds(params.nOperations*1000));
        completedFunctions.fetch_add(1);
    });

    Signal<sigType> signal(params.threadSafe);
    cout << "Connecting " << params.nConnections << " functions" << endl;
    for (uint32_t i = 0; i < params.nConnections; i++) {
        signal.connectSlot(params.scheme, func);
    }

    FunctionTimeRegular<> printer([this]() {
        cout << "Total elements emitted: " << counter << " / " << params.nEmissions << fixed << endl;
        cout << "Emission rate: " << (double) counter / bt.getElapsedMilliseconds() << fixed << "m/ms" << endl;
        cout << "Total elements processed: " << completedFunctions << " / " << params.nEmissions * params.nConnections << fixed << endl;
        cout << "Operation rate: " << (double) completedFunctions * params.nOperations / bt2.getElapsedNanoseconds() << "m/ns" << endl;
        return (bt2.getElapsedSeconds() < 6000);
    }, std::chrono::milliseconds(500));

    FunctionTimeRegular<> checkFinished([this]() {
        return (completedFunctions != params.nEmissions * params.nConnections);
    }, std::chrono::milliseconds(1));

    cout << "Starting emission thread: " << endl;
    
    thread emitter([this, &signal]() {
        bt2.start();
        bt.start();
        for (counter=0; counter<params.nEmissions; ++counter) {
            signal.emitSignal(1);
        }
        bt.stop();
    });
    cout << "Emission thread spawned" << endl;
    
    cout.precision(std::numeric_limits<double>::max_digits10);
    emitter.join();
    cout << "Emission completed" << endl;
    checkFinished.join();
    bt2.stop();
    printer.stopAndJoin();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x288, %rsp            # imm = 0x288
movq %rdi, %rbx
movzbl 0x28(%rdi), %esi
leaq 0x170(%rsp), %rdi
callq 0x1e15a
movq 0x44fda(%rip), %rdi     # 0x5ffb0
leaq 0x20dd6(%rip), %rsi     # 0x3bdb3
callq 0xb4f0
movl 0x18(%rbx), %esi
movq %rax, %rdi
callq 0xb390
leaq 0x20dcb(%rip), %rsi     # 0x3bdbf
movq %rax, %rdi
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
xorl %ebp, %ebp
leaq 0xb6b(%rip), %r12       # 0x1bb78
leaq 0xb8a(%rip), %r13       # 0x1bb9e
leaq 0x170(%rsp), %r14
leaq 0x30(%rsp), %r15
cmpl 0x18(%rbx), %ebp
jae 0x1b055
movl 0x2c(%rbx), %esi
andq $0x0, 0x38(%rsp)
movq %rbx, 0x30(%rsp)
movq %r12, 0x48(%rsp)
movq %r13, 0x40(%rsp)
movq %r14, %rdi
movq %r15, %rdx
callq 0x1bfb4
movq %r15, %rdi
callq 0xd31c
incl %ebp
jmp 0x1b021
leaq 0x50(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movq %rbx, (%rsi)
leaq 0xb5b(%rip), %rax       # 0x1bbc4
movq %rax, 0x18(%rsi)
leaq 0xd00(%rip), %rax       # 0x1bd74
movq %rax, 0x10(%rsi)
leaq 0x10(%rsp), %rdx
movq $0x1f4, (%rdx)          # imm = 0x1F4
leaq 0xe0(%rsp), %rdi
callq 0x1c006
leaq 0x50(%rsp), %rdi
callq 0xd31c
leaq 0x10(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movq %rbx, (%rsi)
leaq 0xceb(%rip), %rax       # 0x1bd9a
movq %rax, 0x18(%rsi)
leaq 0xcf4(%rip), %rax       # 0x1bdae
movq %rax, 0x10(%rsi)
leaq 0x8(%rsp), %rdx
movq $0x1, (%rdx)
leaq 0x50(%rsp), %rdi
callq 0x1c006
leaq 0x10(%rsp), %rdi
callq 0xd31c
movq 0x44ecb(%rip), %rdi     # 0x5ffb0
leaq 0x20cde(%rip), %rsi     # 0x3bdca
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
andq $0x0, 0x8(%rsp)
pushq $0x18
popq %rdi
callq 0xb510
leaq 0x43a72(%rip), %rcx     # 0x5eb80
movq %rcx, (%rax)
movq %rbx, 0x8(%rax)
movq %r14, 0x10(%rax)
leaq 0x10(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0xb4c0
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b13d
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x44e6c(%rip), %r14     # 0x5ffb0
leaq 0x20c9a(%rip), %rsi     # 0x3bde5
movq %r14, %rdi
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
movq (%r14), %rax
movq -0x18(%rax), %rax
movq $0x11, 0x8(%r14,%rax)
leaq 0x8(%rsp), %rdi
callq 0xb9e0
movq 0x44e34(%rip), %rdi     # 0x5ffb0
leaq 0x20c7a(%rip), %rsi     # 0x3bdfd
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
leaq 0xb0(%rsp), %rdi
callq 0xb9e0
addq $0x48, %rbx
movq %rbx, %rdi
callq 0xcbc2
leaq 0xe0(%rsp), %rdi
callq 0x1c0f6
leaq 0x8(%rsp), %rdi
callq 0xd738
leaq 0x50(%rsp), %rdi
callq 0x1c10c
leaq 0xe0(%rsp), %rdi
callq 0x1c10c
leaq 0x170(%rsp), %rdi
callq 0x1e1e6
addq $0x288, %rsp            # imm = 0x288
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x1b23d
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x1b23d
jmp 0x1b226
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xd31c
jmp 0x1b247
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
jmp 0x1b25e
movq %rax, %rbx
jmp 0x1b23d
movq %rax, %rbx
jmp 0x1b263
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xd738
leaq 0x50(%rsp), %rdi
callq 0x1c10c
leaq 0xe0(%rsp), %rdi
callq 0x1c10c
jmp 0x1b263
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0xd31c
leaq 0x170(%rsp), %rdi
callq 0x1e1e6
movq %rbx, %rdi
callq 0xba30