summary refs log tree commit diff
path: root/library/std/src/sys/windows/thread.rs
AgeCommit message (Collapse)AuthorLines
2023-10-24Auto merge of #116461 - ChrisDenton:sleep, r=thomccbors-1/+12
Windows: Support sub-millisecond sleep Use `CreateWaitableTimerExW` with `CREATE_WAITABLE_TIMER_HIGH_RESOLUTION`. Does not work before Windows 10, version 1803 so in that case we fallback to using `Sleep`. I've created a `WaitableTimer` type so it can one day be adapted to also support waiting to an absolute time (which has been talked about). Note though that it currently returns `Err(())` because we can't do anything with the errors other than fallback to the old `Sleep`. Feel free to tell me to do errors properly. It just didn't seem worth constructing an `io::Error` if we're never going to surface it to the user. And it *should* all be infallible anyway unless the OS is too old to support it. Closes #43376
2023-10-06Windows: Support sub-millisecond sleepChris Denton-1/+12
Use `CreateWaitableTimerExW` with `CREATE_WAITABLE_TIMER_HIGH_RESOLUTION`. Does not work before Windows 10, version 1803 so in that case we fallback to using `Sleep`.
2023-10-06Remove libcChris Denton-1/+1
We don't use much libc on Windows.
2023-05-05Use new bindingsChris Denton-2/+3
2023-01-17refactor[std]: do not use box syntaxjoboet-1/+1
2023-01-14Remove various double spaces in source comments.André Vennberg-1/+1
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-1/+0
2022-03-04Rollup merge of #94618 - lewisclark:remove-stack-size-rounding, r=yaahcDylan DPC-4/+1
Don't round stack size up for created threads in Windows Fixes #94454 Windows does the rounding itself, so there isn't a need to explicity do the rounding beforehand, as mentioned by ```@ChrisDenton``` in #94454 > The operating system rounds up the specified size to the nearest multiple of the system's allocation granularity (typically 64 KB). To retrieve the allocation granularity of the current system, use the [GetSystemInfo](https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo) function. https://docs.microsoft.com/en-us/windows/win32/procthread/thread-stack-size
2022-03-04Don't round stack size up for created threadsLewis Clark-4/+1
2022-03-03Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings.Dan Gohman-4/+6
Use the new `HandleOrNull` and `HandleOrInvalid` types that were introduced as part of [I/O safety] in a few functions in the Windows FFI bindings. This factors out an `unsafe` block and two `unsafe` function calls in the Windows implementation code. And, it helps test `HandleOrNull` and `HandleOrInvalid`, which indeed turned up a bug: `OwnedHandle` also needs to be `#[repr(transparent)]`, as it's used inside of `HandleOrNull` and `HandleOrInvalid` which are also `#[repr(transparent)]`. [I/O safety]: https://github.com/rust-lang/rust/issues/87074
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-2/+2
2021-09-28Rename `std::thread::available_onccurrency` to ↵Yoshua Wuyts-1/+1
`std::thread::available_parallelism`
2021-08-19I/O safety.Dan Gohman-2/+3
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd` for relevant types, along with Windows counterparts for handles and sockets. Tracking issue: - <https://github.com/rust-lang/rust/issues/87074> RFC: - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-06-21Move `available_concurrency` implementation to `sys`Christiaan Dirkx-0/+16
2020-07-27mv std libs to library/mark-0/+110