equal
deleted
inserted
replaced
|
1 package org.sipdroid.net.tools; |
|
2 |
|
3 import jlibrtp.DataFrame; |
|
4 |
|
5 public class DataFramePool extends ObjectPool { |
|
6 |
|
7 private static DataFramePool instance = null; |
|
8 public static DataFramePool getInstance() { |
|
9 if(instance == null) { |
|
10 instance = new DataFramePool(20); |
|
11 } |
|
12 return instance; |
|
13 } |
|
14 |
|
15 public static void removeInstance() { |
|
16 instance = null; |
|
17 } |
|
18 |
|
19 protected DataFramePool(int nbObject) { |
|
20 super(nbObject); |
|
21 for(int i = 0; i < nbObject; ++i) { |
|
22 checkIn(create()); |
|
23 } |
|
24 } |
|
25 |
|
26 @Override |
|
27 Object create() { |
|
28 return new DataFrame(); |
|
29 } |
|
30 |
|
31 @Override |
|
32 boolean validate(Object o) { |
|
33 return true; |
|
34 } |
|
35 |
|
36 public DataFrame borrowFrame() { |
|
37 return (DataFrame) super.checkOut(); |
|
38 } |
|
39 |
|
40 public void returnFrame(DataFrame o) { |
|
41 o.release(); |
|
42 super.checkIn(o); |
|
43 } |
|
44 } |