What's mean of size parameter?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

What's mean of size parameter?

yangjun2
public static synchronized <E> CachedTypeIndex<E> obtainIndex(Class<E> clazz, int size) ?
size -----what's mean of it?
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: What's mean of size parameter?

oleksiys
Administrator
It's the max number of objects, which might be cached per thread.

Alexey.

On May 9, 2011, at 10:04 , yangjun2 wrote:

> public static synchronized <E> CachedTypeIndex<E>  
> obtainIndex(Class<E> clazz,
> int size) ?
> size -----what's mean of it?
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/What-s-mean-of-size-parameter-tp4381294p4381294.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: What's mean of size parameter?

yangjun2
Which case must use more than one cache object per thread? It's only a Class object , why use more than one?

yang jun
Best Regards
Best Regards,
Young
Reply | Threaded
Open this post in threaded view
|

Re: What's mean of size parameter?

Ryan Lubke-2
On 5/12/11 4:03 PM, yangjun2 wrote:
> Which case to more than one cache object per thread? It's only a class object
> , why use more than one?

The class argument is to specify the type of objects that will be cached.

For example:

private static final ThreadCache.CachedTypeIndex<Request> CACHE_IDX =
             ThreadCache.obtainIndex(SomeThing.class, 16);

The above statement defines the cache.

Once defined, you can make calls like:

    ThreadCache.takeFromCache(CACHE_IDX);  // obtain a cached instance
    ThreadCache.putToCache(CACHE_IDX, <Instance of Something>);  // push
an instance to the cache

In the example above, the cache will never grow above 16 cached instances.

Does this clarify things?


> yang jun
> Best Regards
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/What-s-mean-of-size-parameter-tp4381294p4391761.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: What's mean of size parameter?

oleksiys
Administrator
In reply to this post by yangjun2
Just one additional note.
More than 1 object might be cached for cases, when we use asynchronous
event processing (suspend/resume event processing), in that case 1
cached object might not be enough.

WBR,
Alexey.

On 05/13/2011 01:03 AM, yangjun2 wrote:
> Which case to more than one cache object per thread? It's only a class object
> , why use more than one?
>
> yang jun
> Best Regards
>
> --
> View this message in context: http://grizzly.1045725.n5.nabble.com/What-s-mean-of-size-parameter-tp4381294p4391761.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.