Daehyun
5/6/2016 - 1:49 AM

inputManager.cpp

#include <string>
#include <iostream>
#include <thread>
#include <functional>
#include <unistd.h>

void inputManager(bool &info) {
    info = false; 
    std::string input;
    while (std::cin) {
        std::cout << "Type something in:" << std::endl;
        std::getline(std::cin, input);
        if(input.empty()){
        	continue;
        }
        std::cout << "You typed [" << input << "]" << std::endl;
        if(input=="q") {
        	info = true; 
        	break; 
        }
    }
    std::cout << "Our work here is done." << std::endl;
}

int main()
{
    bool info;
    std::thread manager(inputManager, std::ref(info));
    
    do {
    	std::cout << "hello world" << std::endl; 
    	usleep(1000000);
    } while(!info);

    manager.join();
    return 0;
}