GNOME Bugzilla – Bug 689863
Add a method to create named threads
Last modified: 2012-12-12 14:09:25 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.
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());
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.
I have pushed the patch to the master branch.