(&mut self)
| 40 | |
| 41 | impl ContextPool { |
| 42 | fn store(&mut self) -> usize { |
| 43 | let id = self.freelist.pop().unwrap_or(self.pool.len()); |
| 44 | if id == self.pool.len() { |
| 45 | self.pool.push(Context { |
| 46 | thread: std::ptr::null_mut(), |
| 47 | ctx: Default::default(), |
| 48 | }) |
| 49 | } |
| 50 | unsafe { |
| 51 | let context = self.pool.get_unchecked_mut(id); |
| 52 | context.thread = ffi::PyThreadState_Get(); |
| 53 | context.ctx = unlimited::store(context.thread); |
| 54 | } |
| 55 | id |
| 56 | } |
| 57 | |
| 58 | fn restore(&mut self, id: usize) { |
| 59 | unsafe { |