Lines Matching refs:Pool
20 // fast because a Box<T> is much smaller than the T we use with a Pool in this
97 /// A Pool<T> impls Sync when T is Send (even if it's not Sync). This means
103 pub struct Pool<T> {
104 /// A stack of T values to hand out. These are used when a Pool is
120 /// the Pool.
124 // SAFETY: Since we want to use a Pool from multiple threads simultaneously
125 // behind an Arc, we need for it to be Sync. In cases where T is sync, Pool<T>
126 // would be Sync. However, since we use a Pool to store mutable scratch space,
128 // Sync. So what we *really* want is for our Pool<T> to by Sync even when T is
131 // The only non-sync aspect of a Pool is its 'owner_val' field, which is used
140 // that created the Pool. Since this can only ever be one thread, it follows
142 // is safe to declare that Pool<T> is Sync when T is Send.
145 // thread that tries to get a value out of a Pool. However, the current
154 unsafe impl<T: Send> Sync for Pool<T> {}
156 impl<T: ::std::fmt::Debug> ::std::fmt::Debug for Pool<T> {
158 f.debug_struct("Pool")
173 pool: &'a Pool<T>,
179 impl<T: Send> Pool<T> {
182 pub fn new(create: CreateFn<T>) -> Pool<T> {
185 Pool { stack: Mutex::new(vec![]), create, owner, owner_val }
290 has_oibits::<Pool<ProgramCache>>();
293 // Tests that Pool implements the "single owner" optimization. That is, the
301 let pool: Arc<Pool<RefCell<Vec<char>>>> =
302 Arc::new(Pool::new(Box::new(|| RefCell::new(vec!['a']))));
330 // Pool's API.)