document functions in the Thread class; add a helper detach() method for future use;

pull/51/head
Bryan Biedenkapp 2 years ago
parent 4acb60aeff
commit 1e8a842a30

@ -58,7 +58,7 @@ bool Thread::run()
}
/// <summary>
///
/// Make calling thread wait for termination of the thread.
/// </summary>
void Thread::wait()
{
@ -66,7 +66,7 @@ void Thread::wait()
}
/// <summary>
///
/// Set thread name visible in the kernel and its interfaces.
/// </summary>
/// <param name="name"></param>
void Thread::setName(std::string name)
@ -80,6 +80,19 @@ void Thread::setName(std::string name)
#endif // _GNU_SOURCE
}
/// <summary>
/// Indicate that the thread is never to be joined with wait().
/// The resources of thread will therefore be freed immediately when it
/// terminates, instead of waiting for another thread to perform wait()
/// on it.
/// </summary>
void Thread::detach()
{
if (!m_started)
return;
::pthread_detach(m_thread);
}
/// <summary>
///
/// </summary>
@ -94,7 +107,7 @@ void Thread::sleep(uint32_t ms)
// ---------------------------------------------------------------------------
/// <summary>
///
/// Internal helper thats used as the entry point for the thread.
/// </summary>
/// <param name="arg"></param>
/// <returns></returns>

@ -39,19 +39,25 @@ public:
/// <summary>User-defined function to run for the thread main.</summary>
virtual void entry() = 0;
/// <summary></summary>
/// <summary>Make calling thread wait for termination of the thread.</summary>
virtual void wait();
/// <summary></summary>
/// <summary>Set thread name visible in the kernel and its interfaces.</summary>
virtual void setName(std::string name);
/// <summary>Indicate that the thread is never to be joined with wait().
/// The resources of thread will therefore be freed immediately when it
/// terminates, instead of waiting for another thread to perform wait()
/// on it.</summary>
virtual void detach();
/// <summary></summary>
static void sleep(uint32_t ms);
private:
pthread_t m_thread;
/// <summary></summary>
/// <summary>Internal helper thats used as the entry point for the thread.</summary>
static void* helper(void* arg);
public:

Loading…
Cancel
Save

Powered by TurnKey Linux.