Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate libc;
- extern crate num_cpus;
- use libc::{c_char, size_t};
- use std::thread;
- use std::fs::copy;
- fn python_str_array_2_str_vec<T, U, V>(_: T, _: U) -> V {
- unimplemented!()
- }
- #[no_mangle]
- pub extern "C" fn copyFiles(
- sources: *const *const c_char,
- destinies: *const *const c_char,
- array_len: size_t,
- ) {
- let src: Vec<&str> = python_str_array_2_str_vec(sources, array_len);
- let dst: Vec<&str> = python_str_array_2_str_vec(destinies, array_len);
- let mut iter = src.iter().zip(dst);
- let num_threads = num_cpus::get();
- let threads = (0..num_threads).map(|_| {
- thread::spawn(|| while let Some((s, d)) = iter.next() {
- copy(s, d);
- })
- });
- for t in threads {
- t.join();
- }
- }
- fn main() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement