mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
An in-memory RNG that shares its file descriptor.
This commit is contained in:
parent
143dfc879e
commit
7ace30f9bd
15 changed files with 203 additions and 23 deletions
|
@ -14,7 +14,7 @@ bitflags = "0.7"
|
|||
bluetooth_traits = {path = "../bluetooth_traits"}
|
||||
device = {git = "https://github.com/servo/devices", features = ["bluetooth-test"]}
|
||||
ipc-channel = "0.5"
|
||||
rand = "0.3"
|
||||
servo_rand = {path = "../rand"}
|
||||
uuid = {version = "0.3.1", features = ["v4"]}
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
|
|
|
@ -7,7 +7,7 @@ extern crate bitflags;
|
|||
extern crate bluetooth_traits;
|
||||
extern crate device;
|
||||
extern crate ipc_channel;
|
||||
extern crate rand;
|
||||
extern crate servo_rand;
|
||||
#[cfg(target_os = "linux")]
|
||||
extern crate tinyfiledialogs;
|
||||
extern crate uuid;
|
||||
|
@ -22,7 +22,7 @@ use bluetooth_traits::scanfilter::{BluetoothScanfilter, BluetoothScanfilterSeque
|
|||
use device::bluetooth::{BluetoothAdapter, BluetoothDevice, BluetoothGATTCharacteristic};
|
||||
use device::bluetooth::{BluetoothGATTDescriptor, BluetoothGATTService};
|
||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||
use rand::Rng;
|
||||
use servo_rand::Rng;
|
||||
use std::borrow::ToOwned;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::string::String;
|
||||
|
@ -397,7 +397,7 @@ impl BluetoothManager {
|
|||
|
||||
fn generate_device_id(&mut self) -> String {
|
||||
let mut device_id;
|
||||
let mut rng = rand::thread_rng();
|
||||
let mut rng = servo_rand::thread_rng();
|
||||
loop {
|
||||
device_id = rng.gen::<u32>().to_string();
|
||||
if !self.cached_devices.contains_key(&device_id) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue