annotate Implab/ObjectPoolWrapper.cs @ 88:c4877ae77cee v2

ServiceLocator: fixed services cleanup
author cin
date Tue, 07 Oct 2014 10:58:38 +0400
parents 34bb2f32634d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82
0363407ee75c added object pool
cin
parents:
diff changeset
1 using System;
0363407ee75c added object pool
cin
parents:
diff changeset
2
0363407ee75c added object pool
cin
parents:
diff changeset
3 namespace Implab {
84
34bb2f32634d minor changes
cin
parents: 82
diff changeset
4 public class ObjectPoolWrapper<T> : IDisposable {
82
0363407ee75c added object pool
cin
parents:
diff changeset
5 readonly T m_value;
0363407ee75c added object pool
cin
parents:
diff changeset
6 readonly ObjectPool<T> m_pool;
0363407ee75c added object pool
cin
parents:
diff changeset
7
0363407ee75c added object pool
cin
parents:
diff changeset
8 internal ObjectPoolWrapper(T value, ObjectPool<T> pool) {
0363407ee75c added object pool
cin
parents:
diff changeset
9 m_value = value;
0363407ee75c added object pool
cin
parents:
diff changeset
10 m_pool = pool;
0363407ee75c added object pool
cin
parents:
diff changeset
11 }
0363407ee75c added object pool
cin
parents:
diff changeset
12
0363407ee75c added object pool
cin
parents:
diff changeset
13 public T Value {
0363407ee75c added object pool
cin
parents:
diff changeset
14 get { return m_value; }
0363407ee75c added object pool
cin
parents:
diff changeset
15 }
0363407ee75c added object pool
cin
parents:
diff changeset
16
0363407ee75c added object pool
cin
parents:
diff changeset
17 #region IDisposable implementation
0363407ee75c added object pool
cin
parents:
diff changeset
18 public void Dispose() {
0363407ee75c added object pool
cin
parents:
diff changeset
19 m_pool.Release(m_value);
0363407ee75c added object pool
cin
parents:
diff changeset
20 }
0363407ee75c added object pool
cin
parents:
diff changeset
21 #endregion
0363407ee75c added object pool
cin
parents:
diff changeset
22 }
0363407ee75c added object pool
cin
parents:
diff changeset
23 }
0363407ee75c added object pool
cin
parents:
diff changeset
24