41 lines
8.9 KiB
HTML
41 lines
8.9 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Classes And Methods - The Support Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheSupportKit.html" title="The Support Kit" /><link rel="prev" href="TheSupportKit_CDT.html" title="Defined Types" /><link rel="next" href="TheSupportKit_Debugging.html" title="Debugging Tools" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheSupportKit_CDT.html" title="Defined Types"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheSupportKit_Debugging.html" title="Debugging Tools"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Classes And Methods - The Support Kit</div></div><div id="headerB">Prev: <a href="TheSupportKit_CDT.html">Defined Types</a> Up: <a href="TheSupportKit.html">The Support Kit</a> Next: <a href="TheSupportKit_Debugging.html">Debugging Tools</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheSupportKit_TLS"></a>Thread Local Storage</h2></div></div></div><div class="informaltable"><table border="0"><colgroup><col /><col /></colgroup><tbody><tr><td>Declared in:</td><td><code class="filename">support/TLS.h</code></td></tr><tr><td>Library:</td><td><code class="filename">libbe.so</code></td></tr></tbody></table></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TLS_Functions"></a>Thread Local Storage Functions</h3></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="tls_allocate"></a>tls_allocate()</h4></div></div></div><a id="id1290422" class="indexterm"></a><code class="methodsynopsis c"><span class="type">int32 </span><span class="methodname">tls_allocate</span>();</code><p>
|
||
Creates and returns a new TLS variable. Each thread in your application
|
||
will have its own copy of this variable; setting the value of the
|
||
variable (through
|
||
<a class="link" href="TheSupportKit_TLS.html#tls_set" title="tls_set(), tls_get()"><code class="function">tls_set()</code></a>)
|
||
in one thread won't affect its value in any
|
||
other thread. You should only allocate a TLS variable once per
|
||
team—you don't have to allocate it in each thread.
|
||
</p><div class="admonition important"><div class="title">Important</div><div class="graphic"><img class="icon" alt="Important" width="32" src="./images/admonitions/Warning_32.png" /><div class="text"><p>The memory for the variable's data isn't allocated by
|
||
<code class="function">tls_allocate()</code>; see
|
||
<a class="link" href="TheSupportKit_TLS.html#tls_set" title="tls_set(), tls_get()"><code class="function">tls_set()</code></a>
|
||
for more information on TLS memory allocation).</p></div></div></div></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="tls_address"></a>tls_address()</h4></div></div></div><a id="id1290490" class="indexterm"></a><code class="methodsynopsis c"><span class="type">void* </span><span class="methodname">tls_address</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">tlsVariable</span></span>);</code><p>
|
||
Returns the address of the memory that holds the value that's referred to
|
||
by <code class="parameter">tlsVariable</code>. <code class="parameter">tlsVariable</code>
|
||
is a TLS variable that must have been created through
|
||
<a class="link" href="TheSupportKit_TLS.html#tls_allocate" title="tls_allocate()"><code class="function">tls_allocate()</code></a>.
|
||
The value returned is valid for the calling thread only.
|
||
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h4 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="tls_set"></a><a id="tls_get"></a>
|
||
tls_set(), tls_get()</h4></div></div></div><a id="id1290553" class="indexterm"></a><a id="id1290560" class="indexterm"></a><code class="methodsynopsis c"><span class="type">void </span><span class="methodname">tls_set</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">tlsVariable</span></span>,<br /> <span class="methodparam"><span class="type">void* </span><span class="parameter">data</span></span>);</code><code class="methodsynopsis c"><span class="type">void* </span><span class="methodname">tls_get</span>(<span class="methodparam"><span class="type">int32 </span><span class="parameter">tlsVariable</span></span>);</code><p>
|
||
<code class="function">tls_set()</code> sets <code class="parameter">tlsVariable</code>
|
||
to refer to <code class="parameter">data</code> within the context of the
|
||
calling thread. <code class="parameter">data</code>, which must already be allocated, can point to data
|
||
of any size or type. The data needn't be the same type or size for each
|
||
thread; for example, a given TLS variable <code class="varname">hodgePodge</code> can refer to a
|
||
string in one thread, an integer in another, an object in another, and so
|
||
on.
|
||
</p><p>
|
||
<code class="function">tls_get()</code> returns a pointer to the data
|
||
referred to by <code class="parameter">tlsVariable</code> within
|
||
the context of the calling thread. If <code class="parameter">tlsVariable</code> hasn't been allocated
|
||
(<a class="link" href="TheSupportKit_TLS.html#tls_allocate" title="tls_allocate()"><code class="function">tls_allocate()</code></a>),
|
||
or if its value hasn't been set (<code class="function">tls_set()</code>), the
|
||
function returns <code class="constant">NULL</code>.
|
||
</p></div></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheSupportKit_CDT.html">Defined Types</a> Up: <a href="TheSupportKit.html">The Support Kit</a> Next: <a href="TheSupportKit_Debugging.html">Debugging Tools</a> </div><div id="footerB"><div id="footerBL"><a href="TheSupportKit_CDT.html" title="Defined Types"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheSupportKit.html" title="The Support Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheSupportKit_Debugging.html" title="Debugging Tools"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|