Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Anders Blomdell
rust-hashtoc
Commits
b223c694
Commit
b223c694
authored
Jan 08, 2019
by
Anders Blomdell
Browse files
Change to a bounded channel
parent
9d52c666
Changes
2
Hide whitespace changes
Inline
Side-by-side
Cargo.toml
View file @
b223c694
[package]
name
=
"hashtoc"
version
=
"0.1.
4
"
version
=
"0.1.
5
"
authors
=
[
"Anders Blomdell <anders.blomdell@control.lth.se>"
]
build
=
"build.rs"
links
=
"libhash.a,libssl"
...
...
src/main.rs
View file @
b223c694
...
...
@@ -29,7 +29,7 @@ use std::ffi::OsStr;
use
std
::
os
::
unix
::
ffi
::
OsStrExt
;
use
std
::
fs
::{
Metadata
};
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
sync
::
mpsc
::{
channel
,
Receiver
,
Sender
};
use
std
::
sync
::
mpsc
::{
sync_
channel
,
Receiver
,
Sync
Sender
};
use
std
::
thread
;
use
std
::
fmt
;
use
std
::
process
::
exit
;
...
...
@@ -178,7 +178,7 @@ struct WorkerPool<T> {
pool
:
ThreadPool
,
pending
:
usize
,
rx
:
Receiver
<
T
>
,
tx
:
Sender
<
T
>
tx
:
Sync
Sender
<
T
>
}
/*trait ExecuteIf {
...
...
@@ -192,7 +192,7 @@ impl ExecuteIf for WorkerPool {
*/
impl
<
T
>
WorkerPool
<
T
>
{
fn
new
(
jobs
:
usize
)
->
WorkerPool
<
T
>
{
let
(
tx
,
rx
)
=
channel
::
<
T
>
();
let
(
tx
,
rx
)
=
sync_
channel
::
<
T
>
(
jobs
*
2
);
WorkerPool
{
pool
:
ThreadPool
::
new
(
jobs
),
pending
:
0
,
...
...
@@ -626,9 +626,9 @@ fn main() -> std::io::Result<()> {
.index
(
1
))
.get_matches
();
let
(
worker
,
tx
)
=
{
let
(
tx
,
rx
)
=
channel
();
let
jobs
=
option_t_or_exit!
(
matches
,
"jobs"
,
usize
)
.unwrap_or
(
1
);
let
(
tx
,
rx
)
=
sync_channel
(
jobs
*
2
);
let
args
=
matches
.clone
();
let
worker
=
thread
::
spawn
(
move
||
{
dispatcher
(
args
,
rx
);
});
(
worker
,
tx
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment