| 51 | // ----------------------------------------------------------------------------------- |
| 52 | |
| 53 | bool spawn_thread ( |
| 54 | void (*funct)(void*), |
| 55 | void* param |
| 56 | ) |
| 57 | { |
| 58 | info* p; |
| 59 | try { p = new info; } |
| 60 | catch (...) { return false; } |
| 61 | |
| 62 | p->funct = funct; |
| 63 | p->param = param; |
| 64 | |
| 65 | |
| 66 | unsigned int garbage; |
| 67 | |
| 68 | HANDLE thandle = (HANDLE)_beginthreadex (NULL,0,thread_starter,p,0,&garbage); |
| 69 | // make thread and add it to the pool |
| 70 | |
| 71 | // return false if _beginthreadex didn't work |
| 72 | if ( thandle == 0) |
| 73 | { |
| 74 | delete p; |
| 75 | return false; |
| 76 | } |
| 77 | |
| 78 | // throw away the thread handle |
| 79 | CloseHandle(thandle); |
| 80 | return true; |
| 81 | } |
| 82 | |
| 83 | // ----------------------------------------------------------------------------------- |
| 84 | |