hxcpp Thread current() fails >.>

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

hxcpp Thread current() fails >.>

luca deltodesco
trace(Thread.current()==Thread.current()); <-- false

checking the generate c++ code. Thread.current() creates a new Thread object on each call to the same handle, and there is a __compare method which compares threads by their handle, but this method isn't actually used to compare Threads as seen in the one line test case >.>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: hxcpp Thread current() fails >.>

luca deltodesco
Note, an important consequence:

var m = new Mutex();
m.acquire();
m.acquire(); <-- blocks, doesn't realise it is the same thread acquiring the mutex.


From: [hidden email]
To: [hidden email]
Date: Sun, 4 Dec 2011 19:56:48 +0000
Subject: [haXe] hxcpp Thread current() fails >.>

trace(Thread.current()==Thread.current()); <-- false

checking the generate c++ code. Thread.current() creates a new Thread object on each call to the same handle, and there is a __compare method which compares threads by their handle, but this method isn't actually used to compare Threads as seen in the one line test case >.>

-- haXe - an open source web programming language http://haxe.org

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

RE: hxcpp Thread current() fails >.>

luca deltodesco
Fix for the mutex issue (doesn't solve Thread.current() issue, but that is less important).

I've posted this also on the hxcpp issue, and hopefully a contributor will see it there or here and make a fix so i don't need to fork hxcpp.

MyMutex constructor in include/hx/Thread.h must be modified as follows:

   MyMutex() { 
        pthread_mutexattr_t mta;
        pthread_mutexattr_init(&mta);                                                    
        pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); 
                
        pthread_mutex_init(&mMutex,&mta);
        mValid = true;
    }  

recursive mutex is required to follow haxe api that the same thread may acquire a mutex multiple times (and require it to release it as many times)


From: [hidden email]
To: [hidden email]
Subject: RE: [haXe] hxcpp Thread current() fails >.>
Date: Sun, 4 Dec 2011 20:00:01 +0000

Note, an important consequence:

var m = new Mutex();
m.acquire();
m.acquire(); <-- blocks, doesn't realise it is the same thread acquiring the mutex.


From: [hidden email]
To: [hidden email]
Date: Sun, 4 Dec 2011 19:56:48 +0000
Subject: [haXe] hxcpp Thread current() fails >.>

trace(Thread.current()==Thread.current()); <-- false

checking the generate c++ code. Thread.current() creates a new Thread object on each call to the same handle, and there is a __compare method which compares threads by their handle, but this method isn't actually used to compare Threads as seen in the one line test case >.>

-- haXe - an open source web programming language http://haxe.org

-- haXe - an open source web programming language http://haxe.org

--
haXe - an open source web programming language
http://haxe.org