For clouds, use a RNG seed that only changes every 10 minutes.
This allows multi-process deploymentes to keep their clouds in sync.
This commit is contained in:
@@ -59,6 +59,11 @@ void mt_init(mt *mt, unsigned int seed)
|
||||
mt->index = MT_N+1;
|
||||
}
|
||||
|
||||
void mt_init_time_10(mt *mt)
|
||||
{
|
||||
mt_init(mt, (unsigned int) time(NULL) / 600);
|
||||
}
|
||||
|
||||
unsigned int mt_rand32(mt *mt)
|
||||
{
|
||||
unsigned int i, y;
|
||||
|
||||
@@ -47,6 +47,13 @@ typedef struct {unsigned int array[MT_N]; int index; } mt;
|
||||
*/
|
||||
void mt_init(mt *mt, unsigned int seed);
|
||||
|
||||
/**
|
||||
* Initialize a new MT state with a seed that only
|
||||
* changes every 10 minutes. Used to synchronize
|
||||
* multi-process deployments.
|
||||
*/
|
||||
void mt_init_time_10(mt *mt);
|
||||
|
||||
/**
|
||||
* Generate a new 32-bit random number based on the given MT state.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user