17a6b944d1
Thread barrier with:
* fixed (at construction) number n of participating threads {T1,T2,T3,...,Tn}
* unknown number of rounds.
Requirements:
* there is some R such that each participating thread makes
R calls to Sync() followed by its one and only call to Exit().
Guarantees:
* for any two threads Ti and Tj and round number r <= R,
everything done by Ti before its r'th call to Sync() happens before
everything done by Tj after its r'th call to Sync().
Note:
* it's not required that the thread that constructs the barrier participates.
BUG=
Review URL: https://codereview.chromium.org//1337943004 .
38 lines
771 B
C++
38 lines
771 B
C++
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
#ifndef VM_RANDOM_H_
|
|
#define VM_RANDOM_H_
|
|
|
|
#include "vm/globals.h"
|
|
#include "vm/allocation.h"
|
|
|
|
namespace dart {
|
|
|
|
class Random {
|
|
public:
|
|
Random();
|
|
// Seed must be non-zero.
|
|
explicit Random(uint64_t seed);
|
|
~Random();
|
|
|
|
uint32_t NextUInt32();
|
|
uint64_t NextUInt64() {
|
|
return (static_cast<uint64_t>(NextUInt32()) << 32) |
|
|
static_cast<uint64_t>(NextUInt32());
|
|
}
|
|
|
|
private:
|
|
void NextState();
|
|
void Initialize(uint64_t seed);
|
|
|
|
uint64_t _state;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Random);
|
|
};
|
|
|
|
} // namespace dart
|
|
|
|
#endif // VM_RANDOM_H_
|