[MUD-Dev] Rooms, 3D arrays, etc.

Jon A. Lambert jlsysinc at ix.netcom.com
Fri Jun 6 21:12:13 New Zealand Standard Time 1997

> From: clawrenc at cup.hp.com
>    at 08:34 PM, "Jon A. Lambert" <jlsysinc at ix.netcom.com> said:
> >Does multi-threading have any affects on seeds used in the random
> >generator.  Does anyone know if this is truly thread safe?
> The standard approach is to make private rand() functions for each
> feature.  This has the benefit of allowing the choice of algorithm for
> each rand() function to be tailored to the task.  The problem is that
> it does not solve the problem if your feature may be called from
> multiple threads (eg multiple threads querying/generating your
> landscape).  Next up is to use per-feature specific rand() functions
> and then add some sort of rand() context to each thread (cf rand
> object) which guarantees the sequence.  

Yes. This would seem to solve the problem.  Generate your own seed table
for use with the terrain generator.  If you are generating terrain
as part of bootup or "area" load this may well end up a single-threaded 
version of rand().  Other functions whose 'normal' use of rand() wouldn't
need the same attention, except for race conditions.

"If I'd known it was harmless, I would have killed it myself"
*- Through a Scanner Darkly - PKD -*


More information about the MUD-Dev mailing list