We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
unix::Client::new
1 parent e1e1ae5 commit be9285fCopy full SHA for be9285f
src/unix.rs
@@ -23,10 +23,20 @@ pub struct Acquired {
23
impl Client {
24
pub fn new(limit: usize) -> io::Result<Client> {
25
let client = unsafe { Client::mk()? };
26
+
27
// I don't think the character written here matters, but I could be
28
// wrong!
- let v: Vec<u8> = vec![b'|'; limit];
29
- (&client.write).write_all(&v)?;
+ //
30
+ // Also, it is highly unlikely to have a machine with more than
31
+ // 128 cores.
32
+ const BUFFER: [u8; 128] = [b'|'; 128];
33
34
+ if BUFFER.len() <= limit {
35
+ (&client.write).write_all(&BUFFER[..limit])?;
36
+ } else {
37
+ (&client.write).write_all(&vec![b'|'; limit])?;
38
+ }
39
40
Ok(client)
41
}
42
0 commit comments