help with classes or threads or something :)

This is a discussion on help with classes or threads or something :) within the C++ Programming forums, part of the General Programming Boards category; having some problem here, don't really know what the question is supposed to be though. I'm using a function MPCreateThread() ...

  1. #1
    btq
    btq is offline
    julie lexx... btq's Avatar
    Join Date
    Jun 2002
    Posts
    161

    help with classes or threads or something :)

    having some problem here, don't really know what the question is supposed to be though.
    I'm using a function MPCreateThread() from the MP library on mac, like MPCreateThread(MyTask, ...) where MyTask is some function. Is it possible to let this function be a member of a class?
    Oh...the question seem to have appeared..
    anyway, I can't get this to work...
    what is it that differs a memberfunction from a non-class funtion, and making this not to work?

    thanks...
    /btqqq

  2. #2
    Unregistered
    Guest
    I dont have a mac and I am not familiar with the library, but I have not in general seen a thread library where you can use a member function of a class as the callback routine.

    FYI class members differ from regular functions in that they implicitly get passed the "this" pointer. How this is done I think is compiler specific, for instance in VC I think the this pointer is passed via the ECX register, but for other compilers I'm sure it's probably different. Thats more or less just trivia, for dopes like us anyway.

    You can declare the member function of the class to be static, and you effectively demote the member of the class to being a regular function ( this is not implicitly passed), but if the library supports it, you may want to look into passing a function object instead, which is probably the "correct" way to do that sort of thing.

    Good luck, hope it helps.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 10-17-2008, 12:28 PM
  2. C++: Threads and Classes
    By newntrue in forum C++ Programming
    Replies: 6
    Last Post: 01-13-2007, 04:06 AM
  3. Classes and Threads
    By Halloko in forum Windows Programming
    Replies: 9
    Last Post: 10-23-2005, 06:27 AM
  4. problem with win32 threads
    By pdmarshall in forum C++ Programming
    Replies: 6
    Last Post: 07-29-2004, 03:39 PM
  5. Block and wake up certain threads
    By Spark in forum C Programming
    Replies: 9
    Last Post: 06-01-2002, 04:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21