Segments to avoid continually creating
and destroying of Segments. A common use of this class would
be:
Segment segment = segmentCache.getSegment(); // do something with segment ... segmentCache.releaseSegment(segment);
| Modifier and Type | Class and Description |
|---|---|
| private static class | SegmentCache.
CachedSegment is used as a tagging interface to determine if a Segment can successfully be shared. |
| Modifier and Type | Field and Description |
|---|---|
| private List | segments
A list of the currently unused Segments. |
| private static SegmentCache | sharedCache
A global cache. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Segment | |
| public static SegmentCache | |
| public static Segment | |
| public void | |
| public static void | releaseSharedSegment(Segment segment)
A convenience method to release a Segment to the shared
|
| segments | back to summary |
|---|---|
| private List<Segment> segments A list of the currently unused Segments. | |
| sharedCache | back to summary |
|---|---|
| private static SegmentCache sharedCache A global cache. | |
| SegmentCache | back to summary |
|---|---|
| public SegmentCache() Creates and returns a SegmentCache. | |
| getSegment | back to summary |
|---|---|
| public Segment getSegment() Returns a | |
| getSharedInstance | back to summary |
|---|---|
| public static SegmentCache getSharedInstance() Returns the shared SegmentCache. | |
| getSharedSegment | back to summary |
|---|---|
| public static Segment getSharedSegment() A convenience method to get a Segment from the shared
| |
| releaseSegment | back to summary |
|---|---|
| public void releaseSegment(Segment segment) Releases a Segment. You should not use a Segment after you release it, and you should NEVER release the same Segment more than once, eg: segmentCache.releaseSegment(segment); segmentCache.releaseSegment(segment);Will likely result in very bad things happening! | |
| releaseSharedSegment | back to summary |
|---|---|
| public static void releaseSharedSegment(Segment segment) A convenience method to release a Segment to the shared
| |
| Access | Constructor and Description |
|---|---|
| private |
| CachedSegment | back to summary |
|---|---|
| private CachedSegment() | |