Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(658)

Side by Side Diff: java/src/org/apache/tomcat/jni/Pool.java

Issue 2842333002: Updated netty-tcnative to version 2.0.0.Final (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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;
21
22 /** Pool
23 *
24 * @author Mladen Turk
25 */
26 public class Pool {
27
28 /**
29 * Create a new pool.
30 * @param parent The parent pool. If this is 0, the new pool is a root
31 * pool. If it is non-zero, the new pool will inherit all
32 * of its parent pool's attributes, except the apr_pool_t will
33 * be a sub-pool.
34 * @return The pool we have just created.
35 */
36 public static native long create(long parent);
37
38 /**
39 * Clear all memory in the pool and run all the cleanups. This also destroys all
40 * subpools.
41 * @param pool The pool to clear
42 * This does not actually free the memory, it just allows the pool
43 * to re-use this memory for the next allocation.
44 */
45 public static native void clear(long pool);
46
47 /**
48 * Destroy the pool. This takes similar action as apr_pool_clear() and then
49 * frees all the memory.
50 * This will actually free the memory
51 * @param pool The pool to destroy
52 */
53 public static native void destroy(long pool);
54
55 /**
56 * Get the parent pool of the specified pool.
57 * @param pool The pool for retrieving the parent pool.
58 * @return The parent of the given pool.
59 */
60 public static native long parentGet(long pool);
61
62 /**
63 * Determine if pool a is an ancestor of pool b
64 * @param a The pool to search
65 * @param b The pool to search for
66 * @return True if a is an ancestor of b, NULL is considered an ancestor
67 * of all pools.
68 */
69 public static native boolean isAncestor(long a, long b);
70
71
72 /*
73 * Cleanup
74 *
75 * Cleanups are performed in the reverse order they were registered. That i s:
76 * Last In, First Out. A cleanup function can safely allocate memory from
77 * the pool that is being cleaned up. It can also safely register additional
78 * cleanups which will be run LIFO, directly after the current cleanup
79 * terminates. Cleanups have to take caution in calling functions that
80 * create subpools. Subpools, created during cleanup will NOT automatically
81 * be cleaned up. In other words, cleanups are to clean up after themselves .
82 */
83
84 /**
85 * Register a function to be called when a pool is cleared or destroyed
86 * @param pool The pool register the cleanup with
87 * @param o The object to call when the pool is cleared
88 * or destroyed
89 * @return The cleanup handler.
90 */
91 public static native long cleanupRegister(long pool, Object o);
92
93 /**
94 * Remove a previously registered cleanup function
95 * @param pool The pool remove the cleanup from
96 * @param data The cleanup handler to remove from cleanup
97 */
98 public static native void cleanupKill(long pool, long data);
99
100 /**
101 * Register a process to be killed when a pool dies.
102 * @param a The pool to use to define the processes lifetime
103 * @param proc The process to register
104 * @param how How to kill the process, one of:
105 * <PRE>
106 * APR_KILL_NEVER -- process is never sent any signals
107 * APR_KILL_ALWAYS -- process is sent SIGKILL on apr_pool_t cleanup
108 * APR_KILL_AFTER_TIMEOUT -- SIGTERM, wait 3 seconds, SIGKILL
109 * APR_JUST_WAIT -- wait forever for the process to complete
110 * APR_KILL_ONLY_ONCE -- send SIGTERM and then wait
111 * </PRE>
112 */
113 public static native void noteSubprocess(long a, long proc, int how);
114
115 /**
116 * Allocate a block of memory from a pool
117 * @param p The pool to allocate from
118 * @param size The amount of memory to allocate
119 * @return The ByteBuffer with allocated memory
120 */
121 public static native ByteBuffer alloc(long p, int size);
122
123 /**
124 * Allocate a block of memory from a pool and set all of the memory to 0
125 * @param p The pool to allocate from
126 * @param size The amount of memory to allocate
127 * @return The ByteBuffer with allocated memory
128 */
129 public static native ByteBuffer calloc(long p, int size);
130
131 /*
132 * User data management
133 */
134
135 /**
136 * Set the data associated with the current pool
137 * @param data The user data associated with the pool.
138 * @param key The key to use for association
139 * @param pool The current pool
140 * <br><b>Warning :</b>
141 * The data to be attached to the pool should have a life span
142 * at least as long as the pool it is being attached to.
143 * Object attached to the pool will be globally referenced
144 * until the pool is cleared or dataSet is called with the null data.
145 * @return APR Status code.
146 */
147 public static native int dataSet(long pool, String key, Object data);
148
149 /**
150 * Return the data associated with the current pool.
151 * @param key The key for the data to retrieve
152 * @param pool The current pool.
153 */
154 public static native Object dataGet(long pool, String key);
155
156 /**
157 * Run all of the child_cleanups, so that any unnecessary files are
158 * closed because we are about to exec a new program
159 */
160 public static native void cleanupForExec();
161
162 }
OLDNEW
« no previous file with comments | « java/src/org/apache/tomcat/jni/Poll.java ('k') | java/src/org/apache/tomcat/jni/PoolCallback.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698