Hi guys,

On 7/27/07, Schmidt, Richard, SDGE1 <[EMAIL PROTECTED]> wrote:
>
> Introduce a
>
> static int Thread::getCurrentThreadId() which is implemented on Win32
> with
>
>    inline static DWORD getCurrentThreadId () {
>       return GetCurrentThreadId();
>     }
>
> On other systems, i don't know the implementation, however there should
> be one.


On systems using pthreads, the function pthread_self() is available and does
the same. The return value is an int, though, so either Win32's
::GetCurrentThreadId() should be casted to int, or pthread_self() should be
casted to unsigned int.

After a look at the internals, I saw that on Windows, the ID is actually the
OS one (assigned upon thread startup), while pthreads and sproc effectively
use the simple counter as said in the documentation of
OpenThreads::Thread::getThreadId(). This brings a subtle difference between
platforms that could be confusing, and as Richard says also prevents any
non-OpenThreads thread from querying the current thread ID through the
OpenThreads interface.

Robert, do you see any objection if the implementation of the thread ID
mechanism is delegated to the underlying threading system, through the
adequate functions ?

I could submit the pthreads and Win32 implementations, but I don't know
sproc at all. I guess it'd be a good idea if all 3 changes could be
atomically committed in the SVN.

To be continued ...

Cheers

Thibault



Richard
>
>
>
>
>
> Hi Richard,
>
> Well if you can think of better solution for the ReentrantMutex feel
> free to suggest one ;-)
>
> Robert.
>
> On 7/26/07, Schmidt, Richard, SDGE1 <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> > Hi,
> >
> > I am not quite sure about the internals of OpenThreads, but
> ReentrantMutex
> > uses a function of "CurrentThread" which returns the current
> OpenThread.
> > However, if the current thread isn't an OpenThread, it seems to return
> NULL.
> >
> >
> >
> > So if you are using the ReentrantMutex with multiple other
> Non-OpenThread
> > Threads it will fail.
> >
> >
> >
> > Richard
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to