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++ MT-multithreading and servers » Different native pthread.h implementations
Re: Different native pthread.h implementations [message #30799 is a reply to message #30784] Sun, 23 January 2011 15:16 Go to previous messageGo to previous message
tojocky is currently offline  tojocky
Messages: 607
Registered: April 2008
Location: UK
Contributor

Mirek,

The main reason of created Thread::GetCurrentId() is to add in Index<Thread::Id>.

I think that for FreeBSD need to change the method Thread::GetCurrentId().

What is your opinion?

Thank you in advance!
Ion.

mirek wrote on Sat, 22 January 2011 14:24

OK, I guess we need temporary solution quite fast, so please check if this works for you:

static String& SockErrorText()
{
	static StaticCriticalSection csect;
	CriticalSection::Lock lock(csect);
	static Index<uintptr_t> thread_index;
	static Array<String> thread_errors;
	static Vector<int> error_ticks;
	int t = msecs();
	if(thread_index.GetCount() >= 1000) {
		for(int i = thread_index.GetCount(); --i >= 0;)
			if(t - error_ticks[i] >= 60000) {
				thread_index.Remove(i);
				thread_errors.Remove(i);
				error_ticks.Remove(i);
			}
	}
#ifdef PLATFORM_WIN32
	uintptr_t tid = GetCurrentThreadId();
#else
	#ifdef _MULTITHREADED
		uintptr_t tid = (uintptr_t)Thread::GetCurrentId();
	#else
		uintptr_t tid = 0;
	#endif
#endif
	int f = thread_index.Find(tid);
	if(f < 0) {
		f = thread_index.GetCount();
		thread_index.Add(tid);
		thread_errors.Add();
		error_ticks.Add();
	}
	error_ticks[f] = t;
	return thread_errors[f];
}



Mirek

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Use same variable in different threads
Next Topic: XmlRpc: possible crash fixed
Goto Forum:
  


Current Time: Sun Jul 06 19:12:56 CEST 2025

Total time taken to generate the page: 0.03625 seconds