gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gnash-commit] gnash/libbase utility.h


From: Dossy Shiobara
Subject: Re: [Gnash-commit] gnash/libbase utility.h
Date: Sat, 29 Mar 2008 16:39:39 -0400
User-agent: Mutt/1.5.17+20080114 (2008-01-14)

On 2008.03.29, Rob Savoye <address@hidden> wrote:
> strk wrote:
> 
> > Can we use the boost::Thread abstraction for this ?
> > I've an assertion in the GC class using operator== to check if "self"
> > is the main thread.
> 
>   I'm not particular how this gets fixed. We can even change it back to
> getpid(), although I do prefer the thread ID in the logs so they make
> more sense. Anything that prints a differing number for each thread is
> fine with me.

What I did was implemented a get_thread_id() that returns pthread_self
if you HAVE_PTHREADS, returns GetCurrentThreadId() if you're _WIN32,
otherwise returns getpid() to gracefully degrade.

The idea is anytime you need the current thread ID--or something that
approximates it--use get_thread_id instead of calling the
platform-specific functions directly.  This is why the function's
signature isn't pthread_t or DWORD but the generic "unsigned long
int"--any casting and/or conversion should be done inside the
function--the caller shouldn't have to care what happens inside the
black box.

We really need more of these platform agnostic abstractions.

-- Dossy

-- 
Dossy Shiobara              | address@hidden | http://dossy.org/
Panoptic Computer Network   | http://panoptic.com/
  "He realized the fastest way to change is to laugh at your own
    folly -- then you can let go and quickly move on." (p. 70)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]