KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tomcat > jni > Shm


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.tomcat.jni;
19
20 import java.nio.ByteBuffer JavaDoc;
21
22 /** Shm
23  *
24  * @author Mladen Turk
25  * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
26  */

27
28 public class Shm {
29
30     /**
31      * Create and make accessable a shared memory segment.
32      * <br />
33      * A note about Anonymous vs. Named shared memory segments:<br />
34      * Not all plaforms support anonymous shared memory segments, but in
35      * some cases it is prefered over other types of shared memory
36      * implementations. Passing a NULL 'file' parameter to this function
37      * will cause the subsystem to use anonymous shared memory segments.
38      * If such a system is not available, APR_ENOTIMPL is returned.
39      * <br />
40      * A note about allocation sizes:<br />
41      * On some platforms it is necessary to store some metainformation
42      * about the segment within the actual segment. In order to supply
43      * the caller with the requested size it may be necessary for the
44      * implementation to request a slightly greater segment length
45      * from the subsystem. In all cases, the apr_shm_baseaddr_get()
46      * function will return the first usable byte of memory.
47      * @param reqsize The desired size of the segment.
48      * @param filename The file to use for shared memory on platforms that
49      * require it.
50      * @param pool the pool from which to allocate the shared memory
51      * structure.
52      * @return The created shared memory structure.
53      *
54      */

55     public static native long create(long reqsize, String JavaDoc filename, long pool)
56         throws Error JavaDoc;
57
58     /**
59      * Remove shared memory segment associated with a filename.
60      * <br />
61      * This function is only supported on platforms which support
62      * name-based shared memory segments, and will return APR_ENOTIMPL on
63      * platforms without such support.
64      * @param filename The filename associated with shared-memory segment which
65      * needs to be removed
66      * @param pool The pool used for file operations
67      */

68     public static native int remove(String JavaDoc filename, long pool);
69
70     /**
71      * Destroy a shared memory segment and associated memory.
72      * @param m The shared memory segment structure to destroy.
73      */

74     public static native int destroy(long m);
75
76     /**
77      * Attach to a shared memory segment that was created
78      * by another process.
79      * @param filename The file used to create the original segment.
80      * (This MUST match the original filename.)
81      * @param pool the pool from which to allocate the shared memory
82      * structure for this process.
83      * @return The created shared memory structure.
84      */

85     public static native long attach(String JavaDoc filename, long pool)
86         throws Error JavaDoc;
87
88     /**
89      * Detach from a shared memory segment without destroying it.
90      * @param m The shared memory structure representing the segment
91      * to detach from.
92      */

93     public static native int detach(long m);
94
95     /**
96      * Retrieve the base address of the shared memory segment.
97      * NOTE: This address is only usable within the callers address
98      * space, since this API does not guarantee that other attaching
99      * processes will maintain the same address mapping.
100      * @param m The shared memory segment from which to retrieve
101      * the base address.
102      * @return address, aligned by APR_ALIGN_DEFAULT.
103      */

104     public static native long baseaddr(long m);
105
106     /**
107      * Retrieve the length of a shared memory segment in bytes.
108      * @param m The shared memory segment from which to retrieve
109      * the segment length.
110      */

111     public static native long size(long m);
112
113     /**
114      * Retrieve new ByteBuffer base address of the shared memory segment.
115      * NOTE: This address is only usable within the callers address
116      * space, since this API does not guarantee that other attaching
117      * processes will maintain the same address mapping.
118      * @param m The shared memory segment from which to retrieve
119      * the base address.
120      * @return address, aligned by APR_ALIGN_DEFAULT.
121      */

122     public static native ByteBuffer JavaDoc buffer(long m);
123
124 }
125
Popular Tags