Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods
Thread::GetCurrentThreadId() and Thread::GetCurrentThreadHandle() new methods [message #30539] Fri, 07 January 2011 16:38 Go to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Hello All,

I propose to add new static methods to Thread class:
class Thread : NoCopy {
public:
#ifdef PLATFORM_WIN32
	typedef HANDLE HandleType;
	typedef dword IdType;
#elif defined(PLATFORM_POSIX)
	typedef pthread_t HandleType;
	typedef pthread_t IdType;
#else
	#error Thread is not support for this platform
#endif
private:
	HandleType     handle;
....
public:
	static IdType GetCurrentThreadId();
	static HandleType GetCurrentThreadHandle();
...


and cpp source c ode:

Thread::IdType Thread::GetCurrentThreadId(){
#ifdef PLATFORM_WIN32
	return GetCurrentThreadId();
#elif defined(PLATFORM_POSIX)
	return pthread_self();
#else
	#error Thread is not support for this platform
#endif
}

Thread::HandleType Thread::GetCurrentThreadHandle(){
#ifdef PLATFORM_WIN32
	return GetCurrentThread();
#elif defined(PLATFORM_POSIX)
	return pthread_self();
#else
	#error Thread is not support for this platform
#endif
}



This method help me to identify the current thread id.

ADD: new method: Thread::GetCurrentThreadHandle

Best regards,
Ion

[Updated on: Fri, 07 January 2011 16:45]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: CppBase/Parser.cpp patch (SVN r2960)
Next Topic: virtual void Ctrl::PaintOver(Draw& w) new method
Goto Forum:
  


Current Time: Tue Apr 30 04:39:57 CEST 2024

Total time taken to generate the page: 0.03006 seconds