Expand description
The declared aspects: WOW64 filesystem redirection, memory priority, and I/O priority.
These are declared, not captured. A declared aspect has nothing to collect from the calling thread, so it is not part of any capture set: the caller states the value it wants installed, and leaving it unspecified means the running thread’s own value is untouched.
§Why each one is declared, and the reasons differ
Stating this per aspect rather than as one blanket claim matters, because the reasons are not the same and only one of them is absolute.
- WOW64 filesystem redirection has no getter at all.
Wow64DisableWow64FsRedirectionyields anOldValueonly as a side effect of disabling redirection, and there is no way to observe the current state without changing it. An aspect that cannot be read cannot be transplanted; this is a mechanical impossibility, not a preference. - Memory priority is readable, through
GetThreadInformation(ThreadMemoryPriority), so this one is a choice. Priority is a policy about how work should compete for resources, not something a caller implicitly consents to having remoted – and silently transplanting it is not the safe default either way, since a caller in a background mode would have its remoted work quietly promoted or demoted without saying so. - I/O priority has no documented getter, and does not move on its own: it changes only in lockstep with CPU and memory priority, through background mode. So there is no independent value to capture even in principle, and declaring background mode declares all three together, which the type says out loud rather than hiding.
§Redirection only does anything in a 32-bit process
Wow64DisableWow64FsRedirection is meaningful only for a 32-bit process on
64-bit Windows. In a 64-bit process there is no redirector to disable and the
call fails. That failure is reported rather than swallowed, because a caller
that asked for redirection to be disabled and silently did not get it would
be reading a different filesystem than it believes.
§Example
use windows_thread_ambient_sys::Declared;
use windows_thread_ambient_sys::declared::MemoryPriority;
let entry = MemoryPriority::current()?;
// Only what is named is installed; every other aspect is left alone.
let declared = Declared::none().with_memory_priority(MemoryPriority::Low);
let during = declared.with_applied(MemoryPriority::current)?;
assert_eq!(during?, MemoryPriority::Low);
// The thread is returned to whatever it had, not to an assumed default.
assert_eq!(MemoryPriority::current()?, entry);Structs§
- Declared
- The declared aspects a caller wants installed.
- Declared
Error - A declared aspect could not be installed or restored.
- Declared
Guard - Holds declared aspects installed until released.
Enums§
- Background
Mode - Whether the thread runs in background processing mode.
- Declared
Aspect - Which declared aspect an operation concerned.
- Memory
Priority - How a thread’s memory pages compete for physical memory.
- Wow64
Redirection - What to do with WOW64 filesystem redirection.