google-code-export / ghostplusplus

Automatically exported from code.google.com/p/ghostplusplus
Other
3 stars 0 forks source link

CreateThread() for general use. #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I am currently using PlaySound() to inform events such as game is hosted/
full/started/over. Only problem is spikes to other running game(s). Replay 
section already has "todotodo: put this in a thread". Is this going to be 
implemented in near future? Could I just copy boost method used in 
CGHostDBMySQL?

Original issue reported on code.google.com by Pabl...@gmail.com on 17 Aug 2009 at 10:24

GoogleCodeExporter commented 9 years ago
sorry, I meant this as "Enhancement" and low priority.

Original comment by Pabl...@gmail.com on 17 Aug 2009 at 10:26

GoogleCodeExporter commented 9 years ago
Yeah, create a new CCallable class just like the ones in ghostdb.h. Allocate 
it, pass
any data you want the thread to have access to into the object, then copy the
CreateThread function from CGHostDBMySQL and run it on your callable. Store the
callable in a data structure such as a vector somewhere, check it occasionally 
to see
if it's ready, and when it is, delete the callable and free any resources you 
gave it.

Be very careful about not touching the callable before it's ready, and in your 
thread
be very careful about not touching any data you weren't explicitly given from 
within
the callable. Also make sure you don't call any non thread safe functions, of 
which
there are a lot.

I'll look into putting that replay code in a thread soon I think.

Original comment by hogantp on 17 Aug 2009 at 3:14