modules/archive/src/main/native/zip/shared/zcpool.c File Reference


Detailed Description

Zip Support for Java VM.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "hyport.h"
#include "zipsup.h"
#include "hypool.h"
#include "hymutex.h"

Functions

BOOLEAN zipCachePool_addCache (HyZipCachePool *zcp, HyZipCache *zipCache)
 Add a new cache to the pool with reference count of 1.
BOOLEAN zipCachePool_addRef (HyZipCachePool *zcp, HyZipCache *zipCache)
 Increment the reference count of a cache in the pool.
HyZipCache * zipCachePool_findCache (HyZipCachePool *zcp, char const *zipFileName, IDATA zipFileNameLength, IDATA zipFileSize, I_64 zipTimeStamp)
 Scans the pool for a cache with matching zipFileName, zipFileSize and zipTimeStamp.
void zipCachePool_kill (HyZipCachePool *zcp)
 Deletes a pool containing shareable zip caches.
HyZipCachePool * zipCachePool_new (HyPortLibrary *portLib)
 Creates a pool to hold shareable zip caches with their reference counts.
BOOLEAN zipCachePool_release (HyZipCachePool *zcp, HyZipCache *zipCache)
 Decrements the reference count of a cache in the pool.


Function Documentation

BOOLEAN zipCachePool_addCache ( HyZipCachePool *  zcp,
HyZipCache *  zipCache 
)

Add a new cache to the pool with reference count of 1.

When reference count reaches zero the pool will automatically be freed.

Parameters:
[in] zcp the zip cache pool that is being added to.
[in] zipCache the zip cache being added.
Returns:
TRUE if successful, FALSE otherwise.
Note:
A cache may only reside in one pool (read: multiple VMs may not share caches with each other).

BOOLEAN zipCachePool_addRef ( HyZipCachePool *  zcp,
HyZipCache *  zipCache 
)

Increment the reference count of a cache in the pool.

Note:
Result is undefined if the cache is not actually in the pool!
Parameters:
[in] zcp the zip cache pool that is being added to.
[in] zipCache the zip cache being added.
Returns:
TRUE if successful, FALSE otherwise.

HyZipCache* zipCachePool_findCache ( HyZipCachePool *  zcp,
char const *  zipFileName,
IDATA  zipFileNameLength,
IDATA  zipFileSize,
I_64  zipTimeStamp 
)

Scans the pool for a cache with matching zipFileName, zipFileSize and zipTimeStamp.

The reference count is incremented and the cache is returned if a match is found.

Parameters:
[in] zcp the zip cache pool to search
[in] zipFileName the name to test for match
[in] zipFileNameLength the length of zipFileName
[in] zipFileSize the size to test for match
[in] zipTimeStamp the time stamp to test for match
Returns:
the matching zip cache

NULL if no match is found.

void zipCachePool_kill ( HyZipCachePool *  zcp  ) 

Deletes a pool containing shareable zip caches.

Parameters:
[in] zcp the zip cache pool that is being deleted
Returns:
none
Note:
Warning: This also deletes remaining caches in the pool, regardless of their reference counts!

HyZipCachePool* zipCachePool_new ( HyPortLibrary portLib  ) 

Creates a pool to hold shareable zip caches with their reference counts.

This should be called once per VM.

Parameters:
[in] portLib the port library
Returns:
a zip cache pool or NULL if one cannot be created

BOOLEAN zipCachePool_release ( HyZipCachePool *  zcp,
HyZipCache *  zipCache 
)

Decrements the reference count of a cache in the pool.

If the reference count reaches 0, the cache is removed from the pool and zipCache_kill is called on it.

Parameters:
[in] zcp the zip cache pool
[in] zipCache the zip cache whose count is being decremented.
Returns:
TRUE if the cache was destroyed

FALSE if the cache is still in the pool.


Genereated on Tue Dec 9 14:12:59 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.