Skip to content
Snippets Groups Projects
Select Git revision
  • 8d68cee028c7f2912aa5998cfda981f5a3ac3d48
  • master default
  • main protected
3 results

test.cpp

Blame
  • test.cpp 669 B
    #include <thread>
    
    #include "log.h"
    
    static void logThread()
    {
    	static int a = 42;
    
    	while(true)
    	{
    		Log(Log::INFO)<<"DEBUG"<<' '<<++a;
    		std::this_thread::sleep_for(std::chrono::microseconds(10));
    	}
    }
    
    static void logThreadTwo()
    {
    	static unsigned int a = 0;
    
    
    	while(true)
    	{
    		a+=2;
    		Log(Log::INFO)<<"DEBUG 2"<<' '<<a;
    		std::this_thread::sleep_for(std::chrono::microseconds(1));
    	}
    }
    
    int main()
    {
    	Log::level = Log::INFO;
    
    	Log(Log::INFO)<<"Starting thread";
    
    	std::thread threadA(logThread);
    	std::thread threadB(logThreadTwo);
    
    	while(true)
    	{
    		Log(Log::INFO)<<"MAIN"<<" Thread";
    		std::this_thread::sleep_for(std::chrono::microseconds(1));
    	}
    
    	return 0;
    }