///
/// Scheduler, Session, and nailgun::Server are intended to be shared between threads, and so their
/// context methods provide immutable references. The remaining types are not intended to be shared
/// between threads, so mutable access is provided.
///
/// TODO: The `Scheduler` and `Session` objects both have lots of internal locks: in general, the GIL
/// should be released (using `py.allow_thread(|| ..)`) before any non-trivial interactions with
/// them. In particular: methods that use the `Graph` should be called outside the GIL. We should
/// make this less error prone: see https://github.com/pantsbuild/pants/issues/11722.
///
Scheduler, Session, and nailgun::Server are intended to be shared between threads, and so their
context methods provide immutable references. The remaining types are not intended to be shared
between threads, so mutable access is provided.


Scheduler Session and nailgun :: Server are intended to be shared between threads and so their context methods provide immutable references . The remaining types are not intended to be shared between threads so mutable access is provided .
fn with_scheduler<F, T>(py: Python, scheduler_ptr: PyScheduler, f: F) -> T
where
  F: FnOnce(&Scheduler) -> T,
{
  let scheduler = scheduler_ptr.scheduler(py);
  scheduler.core.executor.enter(|| f(scheduler))
}
fn with_scheduler < F , T > ( py : Python , scheduler_ptr : PyScheduler , f : F ) -> T where F : FnOnce ( & Scheduler ) -> T , { let scheduler = scheduler_ptr . scheduler ( py ) ; scheduler . core . executor . enter ( | | f ( scheduler ) ) }
Scheduler, Session, and nailgun::Server are intended to be shared between threads, and so their
context methods provide immutable references.
Scheduler Session and nailgun :: Server are intended to be shared between threads and so their context methods provide immutable references .
py
Python
scheduler_ptr
PyScheduler
f
F