⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-threads.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<tbody><tr><td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td><td>data passed to the thread.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td>the return value of the thread, which will be returned by<a class="link" href="glib-Threads.html#g-thread-join"><code class="function">g_thread_join()</code></a>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2883732"></a><h3><a name="GThreadPriority"></a>enum GThreadPriority</h3><a class="indexterm" name="id2883746"></a><pre class="programlisting">typedef enum{  G_THREAD_PRIORITY_LOW,  G_THREAD_PRIORITY_NORMAL,  G_THREAD_PRIORITY_HIGH,  G_THREAD_PRIORITY_URGENT} GThreadPriority;</pre><p>Specifies the priority of a thread. </p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>It is not guaranteed that threads with different priorities reallybehave accordingly. On some systems (e.g. Linux) there are no threadpriorities. On other systems (e.g. Solaris) there doesn't seem to bedifferent scheduling for different priorities. All in all try to avoidbeing dependent on priorities.</p></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a name="G-THREAD-PRIORITY-LOW:CAPS"></a><code class="literal">G_THREAD_PRIORITY_LOW</code></span></p></td><td>a priority lower than normal</td></tr><tr><td><p><span class="term"><a name="G-THREAD-PRIORITY-NORMAL:CAPS"></a><code class="literal">G_THREAD_PRIORITY_NORMAL</code></span></p></td><td>the default priority</td></tr><tr><td><p><span class="term"><a name="G-THREAD-PRIORITY-HIGH:CAPS"></a><code class="literal">G_THREAD_PRIORITY_HIGH</code></span></p></td><td>a priority higher than normal</td></tr><tr><td><p><span class="term"><a name="G-THREAD-PRIORITY-URGENT:CAPS"></a><code class="literal">G_THREAD_PRIORITY_URGENT</code></span></p></td><td>the highest priority</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2883873"></a><h3><a name="GThread"></a>GThread</h3><a class="indexterm" name="id2883885"></a><pre class="programlisting">typedef struct {} GThread;</pre><p>The <a class="link" href="glib-Threads.html#GThread"><span class="type">GThread</span></a> struct represents a running thread. It has three publicread-only members, but the underlying struct is bigger, so you mustnot copy this struct.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Resources for a joinable thread are not fully released until<a class="link" href="glib-Threads.html#g-thread-join"><code class="function">g_thread_join()</code></a> is called for that thread.</p></div></div><hr><div class="refsect2" lang="en"><a name="id2883929"></a><h3><a name="g-thread-create"></a>g_thread_create ()</h3><a class="indexterm" name="id2883942"></a><pre class="programlisting"><a class="link" href="glib-Threads.html#GThread">GThread</a>*            g_thread_create                     (<a class="link" href="glib-Threads.html#GThreadFunc">GThreadFunc</a> func,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> joinable,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>This function creates a new thread with the default priority.</p><p>If <em class="parameter"><code>joinable</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, you can wait for this threads terminationcalling <a class="link" href="glib-Threads.html#g-thread-join"><code class="function">g_thread_join()</code></a>. Otherwise the thread will just disappear whenit terminates. </p><p>The new thread executes the function <em class="parameter"><code>func</code></em> with the argument<em class="parameter"><code>data</code></em>. If the thread was created successfully, it is returned.</p><p><em class="parameter"><code>error</code></em> can be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore errors, or non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to report errors. Theerror is set, if and only if the function returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td><td>a function to execute in the new thread.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td><td>an argument to supply to the new thread.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>joinable</code></em>&#160;:</span></p></td><td>should this thread be joinable?</td></tr><tr><td><p><span class="term"><em class="parameter"><code>error</code></em>&#160;:</span></p></td><td>return location for error.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></p></td><td>the new <a class="link" href="glib-Threads.html#GThread"><span class="type">GThread</span></a> on success.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2884165"></a><h3><a name="g-thread-create-full"></a>g_thread_create_full ()</h3><a class="indexterm" name="id2884178"></a><pre class="programlisting"><a class="link" href="glib-Threads.html#GThread">GThread</a>*            g_thread_create_full                (<a class="link" href="glib-Threads.html#GThreadFunc">GThreadFunc</a> func,                                                         <a class="link" href="glib-Basic-Types.html#gpointer">gpointer</a> data,                                                         <a class="link" href="glib-Basic-Types.html#gulong">gulong</a> stack_size,                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> joinable,                                                         <a class="link" href="glib-Basic-Types.html#gboolean">gboolean</a> bound,                                                         <a class="link" href="glib-Threads.html#GThreadPriority">GThreadPriority</a> priority,                                                         <a class="link" href="glib-Error-Reporting.html#GError">GError</a> **error);</pre><p>This function creates a new thread with the priority <em class="parameter"><code>priority</code></em>. If theunderlying thread implementation supports it, the thread gets a stacksize of <em class="parameter"><code>stack_size</code></em> or the default value for the current platform, if<em class="parameter"><code>stack_size</code></em> is 0.</p><p>If <em class="parameter"><code>joinable</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, you can wait for this threads terminationcalling <a class="link" href="glib-Threads.html#g-thread-join"><code class="function">g_thread_join()</code></a>. Otherwise the thread will just disappear whenit terminates. If <em class="parameter"><code>bound</code></em> is <a class="link" href="glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>, this thread will be scheduled inthe system scope, otherwise the implementation is free to doscheduling in the process scope. The first variant is more expensiveresource-wise, but generally faster. On some systems (e.g. Linux) allthreads are bound.</p><p>The new thread executes the function <em class="parameter"><code>func</code></em> with the argument<em class="parameter"><code>data</code></em>. If the thread was created successfully, it is returned.</p><p><em class="parameter"><code>error</code></em> can be <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to ignore errors, or non-<a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a> to report errors. Theerror is set, if and only if the function returns <a class="link" href="glib-Standard-Macros.html#NULL:CAPS"><code class="literal">NULL</code></a>.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>It is not guaranteed that threads with different priorities reallybehave accordingly. On some systems (e.g. Linux) there are no threadpriorities. On other systems (e.g. Solaris) there doesn't seem to bedifferent scheduling for different priorities. All in all try to avoidbeing dependent on priorities. Use <a class="link" href="glib-Threads.html#G-THREAD-PRIORITY-NORMAL:CAPS"><code class="literal">G_THREAD_PRIORITY_NORMAL</code></a> here as adefault.</p></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>Only use <a class="link" href="glib-Threads.html#g-thread-create-full"><code class="function">g_thread_create_full()</code></a> if you really can't use<a class="link" href="glib-Threads.html#g-thread-create"><code class="function">g_thread_create()</code></a> instead. <a class="link" href="glib-Threads.html#g-thread-create"><code class="function">g_thread_create()</code></a> does not take<em class="parameter"><code>stack_size</code></em>, <em class="parameter"><code>bound</code></em>, and <em class="parameter"><code>priority</code></em> as arguments, as they should onlybe used in cases in which it is unavoidable.</p></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>func</code></em>&#160;:</span></p></td><td>a function to execute in the new thread.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>data</code></em>&#160;:</span></p></td><td>an argument to supply to the new thread.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>stack_size</code></em>&#160;:</span></p></td><td>a stack size for the new thread.</td></tr><tr><td><p><span class="term"><em class="parameter"><code>joinable</code></em>&#160;:</span></p></td><td>should this thread be joinable?</td></tr><tr><td><p><span class="term"><em class="parameter"><code>bound</code></em>&#160;:</span></p></td><td>should this thread be bound to a system thread?

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -