| 147 | } |
| 148 | |
| 149 | inline void Start() { |
| 150 | // do not do this, kids, at home |
| 151 | P_->Ref(); |
| 152 | #if _WIN32_WINNT < 0x0502 |
| 153 | Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, &ThreadId)); |
| 154 | #else |
| 155 | Handle = reinterpret_cast<HANDLE>(::_beginthreadex(nullptr, (unsigned)StackSize(*P_), Proxy, (void*)P_.Get(), 0, nullptr)); |
| 156 | #endif |
| 157 | |
| 158 | if (!Handle) { |
| 159 | P_->UnRef(); |
| 160 | ythrow yexception() << "failed to create a thread"; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | private: |
| 165 | TParamsRef P_; |