Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
systemtools.cpp
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 //=============================================================================
21 // Namespace System Tools
22 //=============================================================================
23 
24 #include <QString>
25 
26 namespace SystemTools
27 {
28 
29 //-----------------------------------------------------------------------------
30 // Get thread name or id
31 //-----------------------------------------------------------------------------
38 
39 QString getThreadName()
40 {
41  QString s;
42 #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
43  unsigned int id = (unsigned int)pthread_self();
44  char buffer[100];
45  pthread_getname_np(pthread_self(),buffer,100);
46  s += "id = " + QString::number(id) + " (" + QString(buffer) + ")";
47 #else
48  s = QString("(thread name not available on this platform)");
49 #endif
50  return s;
51 }
52 
53 
54 //-----------------------------------------------------------------------------
55 // Specify the current thread name
56 //-----------------------------------------------------------------------------
63 
64 void setThreadName (QString threadname)
65 {
66 #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
67  pthread_setname_np (pthread_self(), threadname.toStdString().c_str());
68 #else
69  (void)threadname;
70 #endif
71 }
72 
73 
74 
75 }
void setThreadName(QString threadname)
Helper function for debugging: set the current thread name.
Definition: systemtools.cpp:64
QString getThreadName()
Helper function for debugging: Get the current thread id and time.
Definition: systemtools.cpp:39
Namespace System Tools.
Definition: systemtools.cpp:26