<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.8"/> <title>My Project: SDL_thread.h File Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/search.js"></script> <script type="text/javascript"> $(document).ready(function() { searchBox.OnSelectItem(0); }); </script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">My Project </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.8 --> <script type="text/javascript"> var searchBox = new SearchBox("searchBox", "search",false,'Search'); </script> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> <li> <div id="MSearchBox" class="MSearchBoxInactive"> <span class="left"> <img id="MSearchSelect" src="search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/> <input type="text" id="MSearchField" value="Search" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/> </span><span class="right"> <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> </span> </div> </li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Pages</a></div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <iframe src="javascript:void(0)" frameborder="0" name="MSearchResults" id="MSearchResults"> </iframe> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#typedef-members">Typedefs</a> | <a href="#enum-members">Enumerations</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">SDL_thread.h File Reference</div> </div> </div><!--header--> <div class="contents"> <div class="textblock"><code>#include "<a class="el" href="SDL__stdinc_8h_source.html">SDL_stdinc.h</a>"</code><br /> <code>#include "<a class="el" href="SDL__error_8h_source.html">SDL_error.h</a>"</code><br /> <code>#include "<a class="el" href="SDL__atomic_8h_source.html">SDL_atomic.h</a>"</code><br /> <code>#include "<a class="el" href="SDL__mutex_8h_source.html">SDL_mutex.h</a>"</code><br /> <code>#include "<a class="el" href="begin__code_8h_source.html">begin_code.h</a>"</code><br /> <code>#include "<a class="el" href="close__code_8h_source.html">close_code.h</a>"</code><br /> </div> <p><a href="SDL__thread_8h_source.html">Go to the source code of this file.</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="typedef-members"></a> Typedefs</h2></td></tr> <tr class="memitem:a97cd1dc60cea74b74273affb1a974db5"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a97cd1dc60cea74b74273affb1a974db5"></a> typedef struct SDL_Thread </td><td class="memItemRight" valign="bottom"><b>SDL_Thread</b></td></tr> <tr class="separator:a97cd1dc60cea74b74273affb1a974db5"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ac4db699531ce9f18f5a8547aa988b88e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ac4db699531ce9f18f5a8547aa988b88e"></a> typedef unsigned long </td><td class="memItemRight" valign="bottom"><b>SDL_threadID</b></td></tr> <tr class="separator:ac4db699531ce9f18f5a8547aa988b88e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a07ce005c35ad6ac377d6124db7296026"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a07ce005c35ad6ac377d6124db7296026"></a> typedef unsigned <a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> </td><td class="memItemRight" valign="bottom"><b>SDL_TLSID</b></td></tr> <tr class="separator:a07ce005c35ad6ac377d6124db7296026"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="enum-members"></a> Enumerations</h2></td></tr> <tr class="memitem:acce8dea56f6b307fadd2949b64e3ebda"><td class="memItemLeft" align="right" valign="top">enum  </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#acce8dea56f6b307fadd2949b64e3ebda">SDL_ThreadPriority</a> { <b>SDL_THREAD_PRIORITY_LOW</b>, <b>SDL_THREAD_PRIORITY_NORMAL</b>, <b>SDL_THREAD_PRIORITY_HIGH</b> }</td></tr> <tr class="separator:acce8dea56f6b307fadd2949b64e3ebda"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:a6a64f9be4433e4de6e2f2f548cf3c08e"><td class="memItemLeft" align="right" valign="top">typedef </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> (SDLCALL *SDL_ThreadFunction)(<a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> *data)</td></tr> <tr class="separator:a6a64f9be4433e4de6e2f2f548cf3c08e"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:aca3013d4f50e918b17d2721b37e59082"><td class="memItemLeft" align="right" valign="top">DECLSPEC SDL_Thread *SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#aca3013d4f50e918b17d2721b37e59082">SDL_CreateThread</a> (SDL_ThreadFunction fn, const char *name, <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> *data)</td></tr> <tr class="separator:aca3013d4f50e918b17d2721b37e59082"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:abe2ffa508d85379b355673d557e74d9f"><td class="memItemLeft" align="right" valign="top">DECLSPEC const char *SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#abe2ffa508d85379b355673d557e74d9f">SDL_GetThreadName</a> (SDL_Thread *thread)</td></tr> <tr class="separator:abe2ffa508d85379b355673d557e74d9f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a341933eef1470789de20b05c1392b9ae"><td class="memItemLeft" align="right" valign="top">DECLSPEC SDL_threadID SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#a341933eef1470789de20b05c1392b9ae">SDL_ThreadID</a> (<a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a>)</td></tr> <tr class="separator:a341933eef1470789de20b05c1392b9ae"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a0bf5d93ed5cb25ea59307472c62c66db"><td class="memItemLeft" align="right" valign="top">DECLSPEC SDL_threadID SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#a0bf5d93ed5cb25ea59307472c62c66db">SDL_GetThreadID</a> (SDL_Thread *thread)</td></tr> <tr class="separator:a0bf5d93ed5cb25ea59307472c62c66db"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:adf4da9c0e6a6833bef9741344b09699d"><td class="memItemLeft" align="right" valign="top">DECLSPEC <a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#adf4da9c0e6a6833bef9741344b09699d">SDL_SetThreadPriority</a> (<a class="el" href="SDL__thread_8h.html#acce8dea56f6b307fadd2949b64e3ebda">SDL_ThreadPriority</a> priority)</td></tr> <tr class="separator:adf4da9c0e6a6833bef9741344b09699d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ac96743626ed21d2cdb0868a23cca9705"><td class="memItemLeft" align="right" valign="top">DECLSPEC <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread</a> (SDL_Thread *thread, <a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> *status)</td></tr> <tr class="separator:ac96743626ed21d2cdb0868a23cca9705"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:af90602c51ef5a62f26ed9931af484906"><td class="memItemLeft" align="right" valign="top">DECLSPEC <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#af90602c51ef5a62f26ed9931af484906">SDL_DetachThread</a> (SDL_Thread *thread)</td></tr> <tr class="separator:af90602c51ef5a62f26ed9931af484906"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ac7ed1ec8dec5b902da25b60da2b728fa"><td class="memItemLeft" align="right" valign="top">DECLSPEC SDL_TLSID SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#ac7ed1ec8dec5b902da25b60da2b728fa">SDL_TLSCreate</a> (<a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a>)</td></tr> <tr class="memdesc:ac7ed1ec8dec5b902da25b60da2b728fa"><td class="mdescLeft"> </td><td class="mdescRight">Create an identifier that is globally visible to all threads but refers to data that is thread-specific. <a href="#ac7ed1ec8dec5b902da25b60da2b728fa">More...</a><br /></td></tr> <tr class="separator:ac7ed1ec8dec5b902da25b60da2b728fa"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab519f8d89ea808f32fc139071e6207bb"><td class="memItemLeft" align="right" valign="top">DECLSPEC <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> *SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#ab519f8d89ea808f32fc139071e6207bb">SDL_TLSGet</a> (SDL_TLSID id)</td></tr> <tr class="memdesc:ab519f8d89ea808f32fc139071e6207bb"><td class="mdescLeft"> </td><td class="mdescRight">Get the value associated with a thread local storage ID for the current thread. <a href="#ab519f8d89ea808f32fc139071e6207bb">More...</a><br /></td></tr> <tr class="separator:ab519f8d89ea808f32fc139071e6207bb"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a73a9414493c106d9cb05d1a53d3412fc"><td class="memItemLeft" align="right" valign="top">DECLSPEC <a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> SDLCALL </td><td class="memItemRight" valign="bottom"><a class="el" href="SDL__thread_8h.html#a73a9414493c106d9cb05d1a53d3412fc">SDL_TLSSet</a> (SDL_TLSID id, const <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> *value, <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a>(*destructor)(<a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> *))</td></tr> <tr class="memdesc:a73a9414493c106d9cb05d1a53d3412fc"><td class="mdescLeft"> </td><td class="mdescRight">Set the value associated with a thread local storage ID for the current thread. <a href="#a73a9414493c106d9cb05d1a53d3412fc">More...</a><br /></td></tr> <tr class="separator:a73a9414493c106d9cb05d1a53d3412fc"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <div class="textblock"><p>Header for the SDL thread management routines. </p> </div><h2 class="groupheader">Enumeration Type Documentation</h2> <a class="anchor" id="acce8dea56f6b307fadd2949b64e3ebda"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">enum <a class="el" href="SDL__thread_8h.html#acce8dea56f6b307fadd2949b64e3ebda">SDL_ThreadPriority</a></td> </tr> </table> </div><div class="memdoc"> <p>The SDL thread priority.</p> <dl class="section note"><dt>Note</dt><dd>On many systems you require special privileges to set high priority. </dd></dl> </div> </div> <h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="a6a64f9be4433e4de6e2f2f548cf3c08e"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">typedef int </td> <td>(</td> <td class="paramtype">SDLCALL * </td> <td class="paramname"><em>SDL_ThreadFunction</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>The function passed to <a class="el" href="SDL__thread_8h.html#aca3013d4f50e918b17d2721b37e59082">SDL_CreateThread()</a>. It is passed a void* user context parameter and returns an int. </p> </div> </div> <a class="anchor" id="aca3013d4f50e918b17d2721b37e59082"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC SDL_Thread* SDLCALL SDL_CreateThread </td> <td>(</td> <td class="paramtype">SDL_ThreadFunction </td> <td class="paramname"><em>fn</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>name</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> * </td> <td class="paramname"><em>data</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Create a thread.</p> <p>Thread naming is a little complicated: Most systems have very small limits for the string length (Haiku has 32 bytes, Linux currently has 16, Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll have to see what happens with your system's debugger. The name should be UTF-8 (but using the naming limits of C identifiers is a better bet). There are no requirements for thread naming conventions, so long as the string is null-terminated UTF-8, but these guidelines are helpful in choosing a name:</p> <p><a href="http://stackoverflow.com/questions/149932/naming-conventions-for-threads">http://stackoverflow.com/questions/149932/naming-conventions-for-threads</a></p> <p>If a system imposes requirements, SDL will try to munge the string for it (truncate, etc), but the original string contents will be available from <a class="el" href="SDL__thread_8h.html#abe2ffa508d85379b355673d557e74d9f">SDL_GetThreadName()</a>. </p> </div> </div> <a class="anchor" id="af90602c51ef5a62f26ed9931af484906"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> SDLCALL SDL_DetachThread </td> <td>(</td> <td class="paramtype">SDL_Thread * </td> <td class="paramname"><em>thread</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>A thread may be "detached" to signify that it should not remain until another thread has called <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a> on it. Detaching a thread is useful for long-running threads that nothing needs to synchronize with or further manage. When a detached thread is done, it simply goes away.</p> <p>There is no way to recover the return code of a detached thread. If you need this, don't detach the thread and instead use <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a>.</p> <p>Once a thread is detached, you should usually assume the SDL_Thread isn't safe to reference again, as it will become invalid immediately upon the detached thread's exit, instead of remaining until someone has called <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a> to finally clean it up. As such, don't detach the same thread more than once.</p> <p>If a thread has already exited when passed to <a class="el" href="SDL__thread_8h.html#af90602c51ef5a62f26ed9931af484906">SDL_DetachThread()</a>, it will stop waiting for a call to <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a> and clean up immediately. It is not safe to detach a thread that might be used with <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a>.</p> <p>You may not call <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a> on a thread that has been detached. Use either that function or this one, but not both, or behavior is undefined.</p> <p>It is safe to pass NULL to this function; it is a no-op. </p> </div> </div> <a class="anchor" id="a0bf5d93ed5cb25ea59307472c62c66db"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID </td> <td>(</td> <td class="paramtype">SDL_Thread * </td> <td class="paramname"><em>thread</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Get the thread identifier for the specified thread.</p> <p>Equivalent to <a class="el" href="SDL__thread_8h.html#a341933eef1470789de20b05c1392b9ae">SDL_ThreadID()</a> if the specified thread is NULL. </p> </div> </div> <a class="anchor" id="abe2ffa508d85379b355673d557e74d9f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC const char* SDLCALL SDL_GetThreadName </td> <td>(</td> <td class="paramtype">SDL_Thread * </td> <td class="paramname"><em>thread</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Get the thread name, as it was specified in <a class="el" href="SDL__thread_8h.html#aca3013d4f50e918b17d2721b37e59082">SDL_CreateThread()</a>. This function returns a pointer to a UTF-8 string that names the specified thread, or NULL if it doesn't have a name. This is internal memory, not to be free()'d by the caller, and remains valid until the specified thread is cleaned up by <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a>. </p> </div> </div> <a class="anchor" id="adf4da9c0e6a6833bef9741344b09699d"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC <a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> SDLCALL SDL_SetThreadPriority </td> <td>(</td> <td class="paramtype"><a class="el" href="SDL__thread_8h.html#acce8dea56f6b307fadd2949b64e3ebda">SDL_ThreadPriority</a> </td> <td class="paramname"><em>priority</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Set the priority for the current thread </p> </div> </div> <a class="anchor" id="a341933eef1470789de20b05c1392b9ae"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC SDL_threadID SDLCALL SDL_ThreadID </td> <td>(</td> <td class="paramtype"><a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Get the thread identifier for the current thread. </p> </div> </div> <a class="anchor" id="ac7ed1ec8dec5b902da25b60da2b728fa"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC SDL_TLSID SDLCALL SDL_TLSCreate </td> <td>(</td> <td class="paramtype"><a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Create an identifier that is globally visible to all threads but refers to data that is thread-specific. </p> <dl class="section return"><dt>Returns</dt><dd>The newly created thread local storage identifier, or 0 on error</dd></dl> <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> static SDL_SpinLock tls_lock;</div> <div class="line"><a name="l00002"></a><span class="lineno"> 2</span> static SDL_TLSID thread_local_storage;</div> <div class="line"><a name="l00003"></a><span class="lineno"> 3</span> </div> <div class="line"><a name="l00004"></a><span class="lineno"> 4</span> void SetMyThreadData(void *value)</div> <div class="line"><a name="l00005"></a><span class="lineno"> 5</span> {</div> <div class="line"><a name="l00006"></a><span class="lineno"> 6</span>  if (!thread_local_storage) {</div> <div class="line"><a name="l00007"></a><span class="lineno"> 7</span>  SDL_AtomicLock(&tls_lock);</div> <div class="line"><a name="l00008"></a><span class="lineno"> 8</span>  if (!thread_local_storage) {</div> <div class="line"><a name="l00009"></a><span class="lineno"> 9</span>  thread_local_storage = SDL_TLSCreate();</div> <div class="line"><a name="l00010"></a><span class="lineno"> 10</span>  }</div> <div class="line"><a name="l00011"></a><span class="lineno"> 11</span>  SDL_AtomicUnLock(&tls_lock);</div> <div class="line"><a name="l00012"></a><span class="lineno"> 12</span>  }</div> <div class="line"><a name="l00013"></a><span class="lineno"> 13</span>  SDL_TLSSet(thread_local_storage, value);</div> <div class="line"><a name="l00014"></a><span class="lineno"> 14</span> }</div> <div class="line"><a name="l00015"></a><span class="lineno"> 15</span> </div> <div class="line"><a name="l00016"></a><span class="lineno"> 16</span> void *GetMyThreadData(void)</div> <div class="line"><a name="l00017"></a><span class="lineno"> 17</span> {</div> <div class="line"><a name="l00018"></a><span class="lineno"> 18</span>  return SDL_TLSGet(thread_local_storage);</div> <div class="line"><a name="l00019"></a><span class="lineno"> 19</span> }</div> </div><!-- fragment --><dl class="section see"><dt>See also</dt><dd><a class="el" href="SDL__thread_8h.html#ab519f8d89ea808f32fc139071e6207bb" title="Get the value associated with a thread local storage ID for the current thread. ">SDL_TLSGet()</a> </dd> <dd> <a class="el" href="SDL__thread_8h.html#a73a9414493c106d9cb05d1a53d3412fc" title="Set the value associated with a thread local storage ID for the current thread. ">SDL_TLSSet()</a> </dd></dl> </div> </div> <a class="anchor" id="ab519f8d89ea808f32fc139071e6207bb"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a>* SDLCALL SDL_TLSGet </td> <td>(</td> <td class="paramtype">SDL_TLSID </td> <td class="paramname"><em>id</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Get the value associated with a thread local storage ID for the current thread. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">id</td><td>The thread local storage ID</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>The value associated with the ID for the current thread, or NULL if no value has been set.</dd></dl> <dl class="section see"><dt>See also</dt><dd><a class="el" href="SDL__thread_8h.html#ac7ed1ec8dec5b902da25b60da2b728fa" title="Create an identifier that is globally visible to all threads but refers to data that is thread-specif...">SDL_TLSCreate()</a> </dd> <dd> <a class="el" href="SDL__thread_8h.html#a73a9414493c106d9cb05d1a53d3412fc" title="Set the value associated with a thread local storage ID for the current thread. ">SDL_TLSSet()</a> </dd></dl> </div> </div> <a class="anchor" id="a73a9414493c106d9cb05d1a53d3412fc"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC <a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> SDLCALL SDL_TLSSet </td> <td>(</td> <td class="paramtype">SDL_TLSID </td> <td class="paramname"><em>id</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> * </td> <td class="paramname"><em>value</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a>(*)(<a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> *) </td> <td class="paramname"><em>destructor</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Set the value associated with a thread local storage ID for the current thread. </p> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">id</td><td>The thread local storage ID </td></tr> <tr><td class="paramname">value</td><td>The value to associate with the ID for the current thread </td></tr> <tr><td class="paramname">destructor</td><td>A function called when the thread exits, to free the value.</td></tr> </table> </dd> </dl> <dl class="section return"><dt>Returns</dt><dd>0 on success, -1 on error</dd></dl> <dl class="section see"><dt>See also</dt><dd><a class="el" href="SDL__thread_8h.html#ac7ed1ec8dec5b902da25b60da2b728fa" title="Create an identifier that is globally visible to all threads but refers to data that is thread-specif...">SDL_TLSCreate()</a> </dd> <dd> <a class="el" href="SDL__thread_8h.html#ab519f8d89ea808f32fc139071e6207bb" title="Get the value associated with a thread local storage ID for the current thread. ">SDL_TLSGet()</a> </dd></dl> </div> </div> <a class="anchor" id="ac96743626ed21d2cdb0868a23cca9705"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">DECLSPEC <a class="el" href="SDL__audio_8h.html#a52835ae37c4bb905b903cbaf5d04b05f">void</a> SDLCALL SDL_WaitThread </td> <td>(</td> <td class="paramtype">SDL_Thread * </td> <td class="paramname"><em>thread</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype"><a class="el" href="SDL__thread_8h.html#a6a64f9be4433e4de6e2f2f548cf3c08e">int</a> * </td> <td class="paramname"><em>status</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <p>Wait for a thread to finish. Threads that haven't been detached will remain (as a "zombie") until this function cleans them up. Not doing so is a resource leak.</p> <p>Once a thread has been cleaned up through this function, the SDL_Thread that references it becomes invalid and should not be referenced again. As such, only one thread may call <a class="el" href="SDL__thread_8h.html#ac96743626ed21d2cdb0868a23cca9705">SDL_WaitThread()</a> on another.</p> <p>The return code for the thread function is placed in the area pointed to by <code>status</code>, if <code>status</code> is not NULL.</p> <p>You may not wait on a thread that has been used in a call to <a class="el" href="SDL__thread_8h.html#af90602c51ef5a62f26ed9931af484906">SDL_DetachThread()</a>. Use either that function or this one, but not both, or behavior is undefined.</p> <p>It is safe to pass NULL to this function; it is a no-op. </p> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Thu Oct 16 2014 16:33:09 for My Project by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.8 </small></address> </body> </html>