Multithreading Strategy Qs
-
Hello All.. im new to multithreaded programming and have a couple q's. So far ive got a simple test program working that launches a worker thread via Daniel Lohmann's kewl adapter, but i have a few questions. How do i go about passing data w/ the function? Do i need a Class or struct that encapsulates all the data and pass a ptr of it to the function? Then what about my functions that i need to call from within my thread function... should these just go inside the 'Test' struct that my thread function is in... or are they something like static members of my data class?
-
Hello All.. im new to multithreaded programming and have a couple q's. So far ive got a simple test program working that launches a worker thread via Daniel Lohmann's kewl adapter, but i have a few questions. How do i go about passing data w/ the function? Do i need a Class or struct that encapsulates all the data and pass a ptr of it to the function? Then what about my functions that i need to call from within my thread function... should these just go inside the 'Test' struct that my thread function is in... or are they something like static members of my data class?
Knave777Wave wrote: Do i need a Class or struct that encapsulates all the data and pass a ptr of it to the function? that's what i usually do. Knave777Wave wrote: Then what about my functions that i need to call from within my thread function... should these just go inside the 'Test' struct that my thread function is in... or are they something like static members of my data class? they can go wherever you like. there's really nothing special about the functions a thread calls. maybe you want to keep them in the same file as your thread function for ease-of-maintenance, but it's not strictly necessary. Image Toolkits | Image Processing | Cleek