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 be9285f commit 8abfc60Copy full SHA for 8abfc60
src/unix.rs
@@ -21,7 +21,7 @@ pub struct Acquired {
21
}
22
23
impl Client {
24
- pub fn new(limit: usize) -> io::Result<Client> {
+ pub fn new(mut 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
@@ -31,10 +31,13 @@ impl Client {
31
// 128 cores.
32
const BUFFER: [u8; 128] = [b'|'; 128];
33
34
- if BUFFER.len() <= limit {
+ while limit >= BUFFER.len() {
35
+ (&client.write).write_all(&BUFFER)?;
36
+ limit -= BUFFER.len();
37
+ }
38
+
39
+ if limit > 0 {
40
(&client.write).write_all(&BUFFER[..limit])?;
- } else {
- (&client.write).write_all(&vec![b'|'; limit])?;
41
42
43
Ok(client)
0 commit comments