std::thread

std::thread
  • joinable - std::thread 에 스레드가 있다면 true 리턴한다.
  • get_id - 스레드의 식별 번호.
  • native_handle - 해당 OS의 스레드 핸들.
  • hardware_concurrency - 현재 하드웨어에서 실행할 수 있는 스레드의 갯수를 리턴한다.
  • join - 스레드의 실행이 종료될 때까지 대기.
  • detach - std::thread 인스턴스에서 스레드 제거. 이후 스레드를 std::thread 인스턴스로 제어할 수 없다.
  • swap - std::thread 인스턴스간에 스레드 교환.
std::this_thread
  • yield - 다른 스레드에게 양도.
  • sleep_until - 몇 시까지 중지.
  • sleep_for - 몇 시간 동안 중지.
예제.
std::thread thread = std::thread( [] ( int arg )
{
 std::cout << "Thread arg : " << arg << std::endl;
}, 0 );

class test
{  
public:  
 void print(std::string const& message) const  
 {  
  std::cout<<message<<std::endl;  
 }  
};  
int main()  
{  
 test i;  
 std::thread t(&test::print,&i,"hello!");  
 t.join();  
}

댓글

이 블로그의 인기 게시물

파이썬 vscode에서 자동 코드 정렬. Formatter.

Unity3D git 저장소에 올릴때 필요없는 파일 제외하기. gitignore

플러터(flutter) 개발 참고 사이트들.