After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 689863 - Add a method to create named threads
Add a method to create named threads
Status: RESOLVED FIXED
Product: glibmm
Classification: Bindings
Component: threads
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2012-12-07 20:19 UTC by Andrew Potter
Modified: 2012-12-12 14:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Threads: Add create(name, slot). (3.15 KB, patch)
2012-12-07 20:19 UTC, Andrew Potter
none Details | Review
Threads: Add create(slot, name). (3.45 KB, patch)
2012-12-11 22:52 UTC, Andrew Potter
none Details | Review

Description Andrew Potter 2012-12-07 20:19:44 UTC
Created attachment 230998 [details] [review]
Threads: Add create(name, slot).

Its useful to name threads, so I've wrapped the method. The old nameless thread creation now calls the named version to avoid code duplication.
Comment 1 Kjell Ahlstedt 2012-12-11 18:32:21 UTC
You have used 'const std::string& name' instead of 'const Glib::ustring& name'.
That's reasonable, considering what's said in the description of
g_thread_new(): "Some systems restrict the length of name to 16 bytes."
(16 bytes, not 16 characters) Thus the 'name' parameter is not suitable for
UTF-8 strings. It's probably best to use only 7-bit ASCII characters.
These restrictions ought to be mentioned in the description of @param name.

If you swap the 'name' and 'slot' parameters,

  static Thread* create(const sigc::slot<void>& slot, const std::string& name);

then the two create() methods can be combined to one at the next ABI break,
without breaking API.

  static Thread* create(const sigc::slot<void>& slot,
                        const std::string& name = std::string());
Comment 2 Andrew Potter 2012-12-11 22:52:26 UTC
Created attachment 231312 [details] [review]
Threads: Add create(slot, name).

Updated patch to add the new parameter as the last parameter, and copied glib's documentation about potential length restrictions on name. Also added a TODO to threads.hg to record the intention for when ABI is broken.

My reasoning about using std::string was based on it being a string being passed to the operating system, like a file path. But the potential byte length restriction is even more relevant.
Comment 3 Kjell Ahlstedt 2012-12-12 14:09:25 UTC
I have pushed the patch to the master branch.