[[nullable]]*/
| 522 | } |
| 523 | |
| 524 | /*[[nullable]]*/ CUDTException* get() |
| 525 | { |
| 526 | if (!pthread_getspecific(m_ThreadSpecKey)) |
| 527 | { |
| 528 | // This time if this can't be done due to memory allocation |
| 529 | // problems, just allow this value to be NULL, which during |
| 530 | // getting the error description will redirect to a memory |
| 531 | // allocation error. |
| 532 | |
| 533 | // It would be nice to somehow ensure that this object is |
| 534 | // created in every thread of the application using SRT, but |
| 535 | // POSIX thread API doesn't contain any possibility to have |
| 536 | // a creation callback that would apply to every thread in |
| 537 | // the application (as it is for C++11 thread_local storage). |
| 538 | CUDTException* ne = new(std::nothrow) CUDTException(); |
| 539 | pthread_setspecific(m_ThreadSpecKey, ne); |
| 540 | return ne; |
| 541 | } |
| 542 | return (CUDTException*)pthread_getspecific(m_ThreadSpecKey); |
| 543 | } |
| 544 | |
| 545 | static void ThreadSpecKeyDestroy(void* e) |
| 546 | { |