// File: /workspace/github_cpp_makefile_star2_O2/Barath-Kannan[P]SignalsAndSlots/test/SignalTest_Parametrized.cpp
// Function: SignalTestParametrized_Correctness_Test::TestBody()
TEST_P(SignalTestParametrized, Correctness) {
    std::vector<uint32_t> doneFlags(params.nEmissions, 0);
    auto func = ([this, &doneFlags](sigType x) {
        volatile sigType v = x;
        for (uint32_t i = 0; i < params.nOperations; i++) {
            v+=x;
        }
        doneFlags[x] = 1;
        completedFunctions++;
    });

    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;
    
    std::list<thread> emitters;
    thread emitter([this, &signal]() {
        bt2.start();
        bt.start();
        for (counter=0; counter<params.nEmissions; ++counter) {
            signal.emitSignal(counter);
        }
        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();
    for (uint32_t i=0; i<params.nEmissions; i++) ASSERT_TRUE(doneFlags[i]);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2d8, %rsp            # imm = 0x2D8
movq %rdi, %rbx
movl 0x1c(%rdi), %esi
leaq 0x1c0(%rsp), %rdx
andl $0x0, (%rdx)
leaq 0x88(%rsp), %r15
leaq 0x130(%rsp), %rcx
movq %r15, %rdi
callq 0x1c224
movzbl 0x28(%rbx), %esi
leaq 0x1c0(%rsp), %rdi
callq 0x1e15a
movq 0x453fa(%rip), %rdi     # 0x5ffb0
leaq 0x211f6(%rip), %rsi     # 0x3bdb3
callq 0xb4f0
movl 0x18(%rbx), %esi
movq %rax, %rdi
callq 0xb390
leaq 0x211eb(%rip), %rsi     # 0x3bdbf
movq %rax, %rdi
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
xorl %ebp, %ebp
leaq 0xca1(%rip), %r13       # 0x1b88e
leaq 0xcc8(%rip), %r14       # 0x1b8bc
leaq 0x68(%rsp), %r12
cmpl 0x18(%rbx), %ebp
jae 0x1ac34
movl 0x2c(%rbx), %esi
movq %rbx, 0x68(%rsp)
movq %r15, 0x70(%rsp)
movq %r13, 0x80(%rsp)
movq %r14, 0x78(%rsp)
leaq 0x1c0(%rsp), %rdi
movq %r12, %rdx
callq 0x1bfb4
movq %r12, %rdi
callq 0xd31c
incl %ebp
jmp 0x1abf9
leaq 0xa0(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movq %rbx, (%rsi)
leaq 0xc99(%rip), %rax       # 0x1b8e4
movq %rax, 0x18(%rsi)
leaq 0xe3e(%rip), %rax       # 0x1ba94
movq %rax, 0x10(%rsi)
leaq 0x20(%rsp), %rdx
movq $0x1f4, (%rdx)          # imm = 0x1F4
leaq 0x130(%rsp), %rdi
callq 0x1c006
leaq 0xa0(%rsp), %rdi
callq 0xd31c
leaq 0x20(%rsp), %rsi
andq $0x0, 0x8(%rsi)
movq %rbx, (%rsi)
leaq 0xe26(%rip), %rax       # 0x1baba
movq %rax, 0x18(%rsi)
leaq 0xe2f(%rip), %rax       # 0x1bace
movq %rax, 0x10(%rsi)
leaq 0x50(%rsp), %r15
movq $0x1, (%r15)
leaq 0xa0(%rsp), %rdi
movq %r15, %rdx
callq 0x1c006
leaq 0x20(%rsp), %rdi
callq 0xd31c
movq 0x452e0(%rip), %rdi     # 0x5ffb0
leaq 0x210f3(%rip), %rsi     # 0x3bdca
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
movq %r15, 0x58(%rsp)
movq %r15, 0x50(%rsp)
andq $0x0, 0x60(%rsp)
andq $0x0, 0x8(%rsp)
pushq $0x18
popq %rdi
callq 0xb510
leaq 0x43e07(%rip), %rcx     # 0x5eb10
movq %rcx, (%rax)
movq %rbx, 0x8(%rax)
leaq 0x1c0(%rsp), %rcx
movq %rcx, 0x10(%rax)
leaq 0x20(%rsp), %rsi
movq %rax, (%rsi)
leaq 0x8(%rsp), %rdi
xorl %edx, %edx
callq 0xb4c0
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1ad40
movq (%rdi), %rax
callq *0x8(%rax)
movq 0x45269(%rip), %r14     # 0x5ffb0
leaq 0x21097(%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 0x45231(%rip), %rdi     # 0x5ffb0
leaq 0x21077(%rip), %rsi     # 0x3bdfd
callq 0xb4f0
movq %rax, %rdi
callq 0xb270
leaq 0x100(%rsp), %rdi
callq 0xb9e0
leaq 0x48(%rbx), %rdi
callq 0xcbc2
leaq 0x130(%rsp), %rdi
callq 0x1c0f6
leaq 0x48(%rsp), %r14
xorl %r15d, %r15d
movl 0x1c(%rbx), %eax
cmpq %rax, %r15
jae 0x1ae73
movq 0x88(%rsp), %rax
movl (%rax,%r15,4), %eax
andq $0x0, 0x48(%rsp)
testl %eax, %eax
setne 0x40(%rsp)
je 0x1adf2
movq %r14, %rdi
callq 0x10766
incq %r15
jmp 0x1adbe
leaq 0x18(%rsp), %rdi
callq 0x23d1e
leaq 0x21043(%rip), %rdx     # 0x3be46
leaq 0x21049(%rip), %rcx     # 0x3be53
leaq 0x21048(%rip), %r8      # 0x3be59
leaq 0x20(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x24de3
movq 0x20(%rsp), %r8
leaq 0x20ff9(%rip), %rdx     # 0x3be25
leaq 0x10(%rsp), %rdi
pushq $0x2
popq %rsi
movl $0xa9, %ecx
callq 0x22794
leaq 0x10(%rsp), %rdi
leaq 0x18(%rsp), %rsi
callq 0x22812
leaq 0x10(%rsp), %rdi
callq 0x227f4
leaq 0x20(%rsp), %rdi
callq 0xbb78
leaq 0x18(%rsp), %rdi
callq 0x10720
movq %r14, %rdi
callq 0x10766
leaq 0x8(%rsp), %rdi
callq 0xd738
leaq 0x50(%rsp), %rdi
callq 0x13052
leaq 0xa0(%rsp), %rdi
callq 0x1c10c
leaq 0x130(%rsp), %rdi
callq 0x1c10c
leaq 0x1c0(%rsp), %rdi
callq 0x1e1e6
leaq 0x88(%rsp), %rdi
callq 0x201b6
addq $0x2d8, %rsp            # imm = 0x2D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x227f4
jmp 0x1aedf
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xbb78
jmp 0x1aeee
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x10720
jmp 0x1aefd
movq %rax, %rbx
movq %r14, %rdi
callq 0x10766
jmp 0x1af4a
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1af54
movq (%rdi), %rax
callq *0x8(%rax)
jmp 0x1af54
movq %rax, %rbx
jmp 0x1af54
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0xd31c
jmp 0x1af6b
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
jmp 0x1af82
movq %rax, %rbx
jmp 0x1af5e
movq %rax, %rbx
jmp 0x1af87
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0xd738
leaq 0x50(%rsp), %rdi
callq 0x13052
leaq 0xa0(%rsp), %rdi
callq 0x1c10c
leaq 0x130(%rsp), %rdi
callq 0x1c10c
jmp 0x1af87
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xd31c
leaq 0x1c0(%rsp), %rdi
callq 0x1e1e6
leaq 0x88(%rsp), %rdi
callq 0x201b6
movq %rbx, %rdi
callq 0xba30
nop