Jump to content

misfit382

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by misfit382

  1. 11 minutes ago, Josh said:

    Is port_scanner::test2 a static function?

    Maybe try to create a simple example and post the code so we can test it.

    Sure, here u go with main.cpp file - should be enough to show the problem. I can't afford to use static functions in this case.

    #include "UltraEngine.h"
    
    using namespace UltraEngine;
    
    class testclass {
    private:
        void test2(const int start, const int size);
        void test();
    };
    
    void testclass::test2(const int start, const int size)
    {
        int i;
        for (int num = start; num <= start + size; num++) {
            //something here
        }
    }
    
    void testclass::test() {
        int thread_count = 40;
        int range = 65535;
        vector<shared_ptr<Thread> > threads(thread_count);
        for (int n = 0; n < thread_count; ++n)
        {
            threads[n] = CreateThread(bind((test2), range / thread_count * n, range / thread_count), true);
        }
        for (int n = 0; n < 40; ++n)
        {
            threads[n]->Wait();
        }
    }
    int main(int argc, const char* argv[])
    {
      
        return 0;
    }

     

  2. Hi,
    I have encountered a problem using threads with the help of classes. I have been using sample codes so far as well as browsing the forum, but unfortunately I cannot find an answer to this problem.
    Following the guide about threads I got something like this

    image.thumb.png.965a37a6be3bf26891d113b5a02c4a5d.png

    Unfortunately I don't understand why a function of void type not belonging to a class passes in the compilation without any problem, but in the other direction it doesn't.

    I apologize for bothering you with probably simple problems and for my poor English

    Thanks

×
×
  • Create New...