Is there a way in which I can spawn a thread in a cross-platform way?

AFAIK threads are inherently a platform specific device, and at one time
could not be counted on even being present on a platform (Linux has had a
few versions of 'threads' over the years, in fact, it hasn't always even
supported them, like about the time HL was released there were none IIRC).


Is it
possible to do this without #ifdef'ing code for Windows and Linux?

Yes, and the answer is related to the above, you don't need to use
conditional compilation all over the place to isolate platform differences,
but in one spot, you write three classes to perform the platform specific
things, one is a windows-only version of the code, one is a linux only
version of the code, and one is the abstraction layer (i.e. abstract base
class interface), then you have a single #if def to determine the platform
(or do something trickier at runtime, but really the ifdef is a reasonable
choice). You only have one instance of the three classes, a pointer to the
parent class, which is set equal to the sub classes depending on where
you're running -- windows/linux.

Wendy Jones has an article which shows off a simple technique in 'Game
Programming Tricks of the Trade', it more applies to things that run on
consoles and PC's, but the technique is useful in general for isolating
platform specific things. But the above would get someone started. Probably
one would make the thing a singleton, but the basic concept in no way
requires that.

--
Thanks,
Lachlan

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives,
please visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders



_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to