이거 쓰면 Thread를 그룹으로 묶어서 쓸수 있심..

사용법은 아래 보셈..

#include "boost/thread.hpp"

class threadFunc
{
    int m_a;
public:
    threadFunc( int a )
    {
        m_a = a;
    }

    void operator()()  
    {  
        printf("[%d]일단 들어왔네!!! [%d]\n", boost::this_thread::get_id(), m_a );

        Sleep(5000);

        printf("[%d] 끝났네 [%d]\n", boost::this_thread::get_id(), m_a );
    }  
};

int main()
{
    boost::thread_group tg;

    tg.create_thread( threadFunc(1) );                        // 1번 스래드 생성 
    tg.add_thread(new boost::thread( threadFunc(2) ) );        // 2번 스래드 생성 
    tg.add_thread(new boost::thread( threadFunc(3) ) );        // 3번 스래드 생성 

    //모든 스래드가 종료 될때까지 대기 
    tg.join_all();

    return 0;
}

by 널부러 2012. 10. 16. 22:36

문자를 숫자로 or 숫자를 문자로 바꿀때 사용 한다.

사용법은 간단하다.. 아래보셈..

#include "boost/lexical_cast.hpp"

int main()
{
    std::string input = "1";
    int output = 0;

    try
    {
        convertDta = boost::lexical_cast<int>( inputValue );
    }
    catch(boost::bad_lexical_cast &e)
    {
        // 변경이 안되면 아래 에러 출력
        printf("%s\n", e.what() );
        return false;
    }

    return 0;
}

그런데 이거 잘 써먹지는 못할듯..

문제가 2가지가 있심.. BYTE(unsigned char) 변환이 잘 안된다는거 하고

atoi(itoa), stringstream 등으로 변환하는거보단 촐랭 느리다는거...

아무튼 오늘도 뭔가 하나 올림..



by 널부러 2012. 10. 16. 21:38
| 1 |