annotate Implab/ObjectPoolWrapper.cs @ 83:397fe8db0806 v2

fixed object pool
author cin
date Mon, 29 Sep 2014 15:49:15 +0400
parents 0363407ee75c
children 34bb2f32634d
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 {
0363407ee75c added object pool
cin
parents:
diff changeset
4 public struct ObjectPoolWrapper<T> : IDisposable {
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