Skip to content

Commit

Permalink
Remove docs abour low level api to limits
Browse files Browse the repository at this point in the history
  • Loading branch information
ohadravid committed Jan 25, 2024
1 parent 2e24b87 commit 3765887
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 32 deletions.
4 changes: 1 addition & 3 deletions src/job.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ impl Job {
}

/// Create an anonymous job object and sets it's limit according to `info`.
/// Note: This method shouldn't change the provided `info`, but the internal Windows API
/// require a mutable pointer, which means this function requires &mut as well.
pub fn create_with_limit_info(info: &mut ExtendedLimitInfo) -> Result<Self, JobError> {
pub fn create_with_limit_info(info: &ExtendedLimitInfo) -> Result<Self, JobError> {
let job = Self::create()?;
job.set_extended_limit_info(info)?;

Expand Down
31 changes: 2 additions & 29 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//! or by creating an empty one using `new()`, use helper methods to configure
//! the required limits, and finally set the info to the job.
//!
//! ```edition2018
//! ```edition2021
//! use win32job::*;
//! # fn main() -> Result<(), JobError> {
//!
Expand All @@ -28,7 +28,7 @@
//! ```
//!
//! Which is equivalnent to:
//! ```edition2018
//! ```edition2021
//! use win32job::*;
//! # fn main() -> Result<(), JobError> {
//!
Expand All @@ -45,33 +45,6 @@
//! # Ok(())
//! # }
//! ```
//!
//! # Using the low level API
//!
//! The most basic API is getting an `ExtendedLimitInfo` object and
//! manipulating the raw `JOBOBJECT_BASIC_LIMIT_INFORMATION`, and then set it back to the job.
//!
//! It's important to remeber to set the needed `LimitFlags` for each limit used.
//!
//! ```edition2018
//! use win32job::*;
//! # fn main() -> Result<(), JobError> {
//! use windows::Win32::System::JobObjects::JOB_OBJECT_LIMIT_WORKINGSET;
//!
//! let job = Job::create()?;
//! let mut info = job.query_extended_limit_info()?;
//!
//! info.0.BasicLimitInformation.MinimumWorkingSetSize = 1 * 1024 * 1024;
//! info.0.BasicLimitInformation.MaximumWorkingSetSize = 4 * 1024 * 1024;
//! info.0.BasicLimitInformation.LimitFlags |= JOB_OBJECT_LIMIT_WORKINGSET;
//!
//! job.set_extended_limit_info(&mut info)?;
//! job.assign_current_process()?;
//! # info.clear_limits();
//! # job.set_extended_limit_info(&mut info)?;
//! # Ok(())
//! # }
//! ```
mod error;
mod job;
mod limits;
Expand Down
1 change: 1 addition & 0 deletions src/limits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use windows::Win32::System::{
#[derive(Debug)]
pub struct ExtendedLimitInfo(pub(crate) JOBOBJECT_EXTENDED_LIMIT_INFORMATION);

#[derive(Debug, Clone, Copy)]
#[repr(u32)]
pub enum PriorityClass {
Normal = NORMAL_PRIORITY_CLASS.0,
Expand Down

0 comments on commit 3765887

Please sign in to comment.