Thread: Multiprocessing?

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    145

    Multiprocessing?

    Okay, I want to be able to do two or more things at once, and so far all I could find on the topic was multiprocessing. The problem is, I don't know how the heck to do this.
    The easiest example of what I am asking for here would be a racing game. I want the clock to tick down, even if the user sits there doing nothing, while at the same time checking to see what key they press.
    Anyhow, I am unsure how to do this and any help would be appreciated, thanks alot.
    "Um...well..."
    -Kyoto Oshiro

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    For Win32 you might do:

    Code:
    DWORD WINAPI my_func(void*param){
    cout << "Thread running.";
    }
    
    HANDLE thread = CreateThread(NULL, 0, my_func, (void*)my_func_param, 0, &thread_id);
    BTW: the function must have that exact signature, whether you use the parameter or not. If you don't want to pass one ( a parameter) you can leave the 4th argument to CreateThread NULL.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    145

    Thanks

    Thanks, that was the code I was looking for.
    "Um...well..."
    -Kyoto Oshiro

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    21

    FAQ material

    ^-----^

    Could someone fill in the finer details?
    I'm looking it up now.
    Last edited by anobody; 10-21-2002 at 02:00 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Multiprocessing variation question
    By Kyoto Oshiro in forum C++ Programming
    Replies: 4
    Last Post: 11-21-2002, 06:43 PM