blob: c1a0cd8fed0002dd455f9c96606d71b6d0296afe [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Writing GLib Applications: GLib Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="GLib Reference Manual">
<link rel="up" href="glib.html" title="GLib Overview">
<link rel="prev" href="glib-cross-compiling.html" title="Cross-compiling the GLib package">
<link rel="next" href="glib-compiling.html" title="Compiling GLib Applications">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts"></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="glib.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="glib-cross-compiling.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="glib-compiling.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="glib-programming"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle">Writing GLib Applications</span></h2>
<p>Writing GLib Applications —
General considerations when programming with GLib
</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="id-1.2.5.3"></a><h2>Writing GLib Applications</h2>
<div class="refsect2">
<a name="id-1.2.5.3.2"></a><h3>Threads</h3>
<p>
The general policy of GLib is that all functions are invisibly threadsafe
with the exception of data structure manipulation functions, where, if
you have two threads manipulating the <span class="emphasis"><em>same</em></span> data
structure, they must use a lock to synchronize their operation.
</p>
<p>
GLib creates a worker thread for its own purposes so GLib applications
will always have at least 2 threads.
</p>
<p>
See the sections on <a class="link" href="glib-Threads.html" title="Threads">threads</a> and
<a class="link" href="glib-Thread-Pools.html" title="Thread Pools">threadpools</a> for GLib APIs that
support multithreaded applications.
</p>
</div>
<hr>
<div class="refsect2">
<a name="id-1.2.5.3.3"></a><h3>Security</h3>
<p>
When writing code that runs with elevated privileges, it is important
to follow some basic rules of secure programming. David Wheeler has an
excellent book on this topic,
<a class="ulink" href="http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO/index.html" target="_top">Secure Programming for Linux and Unix HOWTO</a>.
</p>
<p>
When it comes to GLib and its associated libraries, GLib and
GObject are generally fine to use in code that runs with elevated
privileges; they don't load modules (executable code in shared objects)
or run other programs 'behind your back'. GIO has to be used
carefully in privileged programs, see the <a class="ulink" href="http://developer.gnome.org/gio/stable/ch02.html" target="_top">GIO documentation</a> for details.
</p>
</div>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>