~ubuntu-branches/debian/jessie/glib2.0/jessie

« back to all changes in this revision

Viewing changes to glib/gmain.c

  • Committer: Package Import Robot
  • Author(s): Iain Lane
  • Date: 2014-09-23 10:12:15 UTC
  • mfrom: (1.66.20)
  • Revision ID: package-import@ubuntu.com-20140923101215-3vlqvooralbmzq8t
Tags: 2.42.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1854
1854
 *
1855
1855
 * It is permitted to call this function multiple times, but is not
1856
1856
 * recommended due to the potential performance impact.  For example,
1857
 
 * one could change the name in the "check" function of a #GSourceFuncs 
 
1857
 * one could change the name in the "check" function of a #GSourceFuncs
1858
1858
 * to include details like the event type in the source name.
1859
1859
 *
 
1860
 * Use caution if changing the name while another thread may be
 
1861
 * accessing it with g_source_get_name(); that function does not copy
 
1862
 * the value, and changing the value will free it while the other thread
 
1863
 * may be attempting to use it.
 
1864
 *
1860
1865
 * Since: 2.26
1861
1866
 **/
1862
1867
void
1863
1868
g_source_set_name (GSource    *source,
1864
1869
                   const char *name)
1865
1870
{
 
1871
  GMainContext *context;
 
1872
 
1866
1873
  g_return_if_fail (source != NULL);
1867
1874
 
 
1875
  context = source->context;
 
1876
 
 
1877
  if (context)
 
1878
    LOCK_CONTEXT (context);
 
1879
 
1868
1880
  /* setting back to NULL is allowed, just because it's
1869
1881
   * weird if get_name can return NULL but you can't
1870
1882
   * set that.
1872
1884
 
1873
1885
  g_free (source->name);
1874
1886
  source->name = g_strdup (name);
 
1887
 
 
1888
  if (context)
 
1889
    UNLOCK_CONTEXT (context);
1875
1890
}
1876
1891
 
1877
1892
/**
1878
1893
 * g_source_get_name:
1879
1894
 * @source: a #GSource
1880
1895
 *
1881
 
 * Gets a name for the source, used in debugging and profiling.
1882
 
 * The name may be #NULL if it has never been set with
1883
 
 * g_source_set_name().
 
1896
 * Gets a name for the source, used in debugging and profiling.  The
 
1897
 * name may be #NULL if it has never been set with g_source_set_name().
1884
1898
 *
1885
1899
 * Returns: the name of the source
 
1900
 *
1886
1901
 * Since: 2.26
1887
1902
 **/
1888
1903
const char *
1903
1918
 * This is a convenience utility to set source names from the return
1904
1919
 * value of g_idle_add(), g_timeout_add(), etc.
1905
1920
 *
 
1921
 * It is a programmer error to attempt to set the name of a non-existent
 
1922
 * source.
 
1923
 *
 
1924
 * More specifically: source IDs can be reissued after a source has been
 
1925
 * destroyed and therefore it is never valid to use this function with a
 
1926
 * source ID which may have already been removed.  An example is when
 
1927
 * scheduling an idle to run in another thread with g_idle_add(): the
 
1928
 * idle may already have run and been removed by the time this function
 
1929
 * is called on its (now invalid) source ID.  This source ID may have
 
1930
 * been reissued, leading to the operation being performed against the
 
1931
 * wrong source.
 
1932
 *
1906
1933
 * Since: 2.26
1907
1934
 **/
1908
1935
void
2043
2070
 *
2044
2071
 * Finds a #GSource given a pair of context and ID.
2045
2072
 *
2046
 
 * Returns: (transfer none): the #GSource if found, otherwise, %NULL
 
2073
 * It is a programmer error to attempt to lookup a non-existent source.
 
2074
 *
 
2075
 * More specifically: source IDs can be reissued after a source has been
 
2076
 * destroyed and therefore it is never valid to use this function with a
 
2077
 * source ID which may have already been removed.  An example is when
 
2078
 * scheduling an idle to run in another thread with g_idle_add(): the
 
2079
 * idle may already have run and been removed by the time this function
 
2080
 * is called on its (now invalid) source ID.  This source ID may have
 
2081
 * been reissued, leading to the operation being performed against the
 
2082
 * wrong source.
 
2083
 *
 
2084
 * Returns: (transfer none): the #GSource
2047
2085
 **/
2048
2086
GSource *
2049
2087
g_main_context_find_source_by_id (GMainContext *context,
2178
2216
 *
2179
2217
 * It is a programmer error to attempt to remove a non-existent source.
2180
2218
 *
 
2219
 * More specifically: source IDs can be reissued after a source has been
 
2220
 * destroyed and therefore it is never valid to use this function with a
 
2221
 * source ID which may have already been removed.  An example is when
 
2222
 * scheduling an idle to run in another thread with g_idle_add(): the
 
2223
 * idle may already have run and been removed by the time this function
 
2224
 * is called on its (now invalid) source ID.  This source ID may have
 
2225
 * been reissued, leading to the operation being performed against the
 
2226
 * wrong source.
 
2227
 *
2181
2228
 * Returns: For historical reasons, this function always returns %TRUE
2182
2229
 **/
2183
2230
gboolean