Skip to content

Commit

Permalink
Implement Send + Sync for Job, bump version to 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadravid committed Aug 12, 2022
1 parent 3ac1dd3 commit 2e6365a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "win32job"
version = "1.0.1"
version = "1.0.2"
authors = ["Ohad Ravid <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
3 changes: 3 additions & 0 deletions src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ pub struct Job {
handle: HANDLE,
}

unsafe impl Send for Job {}
unsafe impl Sync for Job {}

impl Job {
/// Create an anonymous job object.
pub fn create() -> Result<Self, JobError> {
Expand Down
11 changes: 3 additions & 8 deletions src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,15 @@ mod tests {
info.limit_working_memory(min, max);

job.set_extended_limit_info(&mut info).unwrap();
job.assign_current_process().unwrap();

let test_vec_size = 8 * 1024 * 1024;
let test_vec_size = max * 4;
let mut big_vec: Vec<u8> = Vec::with_capacity(test_vec_size);
big_vec.resize_with(test_vec_size, || 1);

let memory_info = get_process_memory_info(get_current_process()).unwrap();
println!("{}", memory_info.WorkingSetSize);
assert!(memory_info.WorkingSetSize >= max);

job.assign_current_process().unwrap();

let memory_info = get_process_memory_info(get_current_process()).unwrap();

assert!(memory_info.WorkingSetSize <= max);
assert!(memory_info.WorkingSetSize <= max * 2);

info.clear_limits();

Expand Down

0 comments on commit 2e6365a

Please sign in to comment.