commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r805689 - /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
Date Wed, 19 Aug 2009 07:41:21 GMT
Author: mturk
Date: Wed Aug 19 07:41:21 2009
New Revision: 805689

URL: http://svn.apache.org/viewvc?rev=805689&view=rev
Log:
Add SharedMemory prototype class

Added:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
  (with props)

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java?rev=805689&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
(added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
Wed Aug 19 07:41:21 2009
@@ -0,0 +1,194 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.runtime;
+
+import java.io.IOException;
+import org.apache.commons.runtime.io.File;
+import org.apache.commons.runtime.exception.OperatingSystemException;
+import org.apache.commons.runtime.exception.UnsupportedOperatingSystemException;
+
+/**
+ * SharedMemory class.
+ * <p>
+ * <b>Warning:</b><br/>Using this class improperly may crash the running
JVM.
+ * </p>
+ *
+ * @since Runtime 1.0
+ */
+public final class SharedMemory
+{
+
+    /*
+     * Reference to the OS shared memory descriptor
+     */
+    private Descriptor shm;
+
+    private SharedMemory()
+    {
+        // No Instance
+    }
+
+    /**
+     * Create and make accessable anonymous shared memory segment.
+     * <p>
+     * A note about Anonymous vs. Named shared memory segments:<br />
+     *         Not all plaforms support anonymous shared memory segments, but in
+     *         some cases it is prefered over other types of shared memory
+     *         implementations. If such a system is not available,
+     *         {@code UnsupportedOperatingSystemException} is thrown.
+     * </p>
+     * <p>
+     * A note about allocation sizes:<br />
+     *         On some platforms it is necessary to store some metainformation
+     *         about the segment within the actual segment. In order to supply
+     *         the caller with the requested size it may be necessary for the
+     *         implementation to request a slightly greater segment length
+     *         from the subsystem. In all cases, the {@code get()}
+     *         function will return the first usable byte of memory.
+     * </p>
+     * @param reqsize The desired size of the segment.
+     * @param name The file to use for shared memory on platforms that
+     *        require it.
+     */
+    public static SharedMemory create(long size)
+    {
+        return null;
+    }
+
+    /**
+     * Create and make accessable a shared memory segment.
+     * <p>
+     * A note about Anonymous vs. Named shared memory segments:<br />
+     *         Not all plaforms support anonymous shared memory segments, but in
+     *         some cases it is prefered over other types of shared memory
+     *         implementations. If such a system is not available,
+     *         {@code UnsupportedOperatingSystemException} is thrown.
+     * </p>
+     * <p>
+     * A note about allocation sizes:<br />
+     *         On some platforms it is necessary to store some metainformation
+     *         about the segment within the actual segment. In order to supply
+     *         the caller with the requested size it may be necessary for the
+     *         implementation to request a slightly greater segment length
+     *         from the subsystem. In all cases, the {@code get()}
+     *         function will return the first usable byte of memory.
+     * </p>
+     * @param reqsize The desired size of the segment.
+     * @param file The abstract file path to use for shared memory on platforms
+     *             that require it.
+     */
+    public static SharedMemory create(File file, long size)
+    {
+        return null;
+    }
+
+    /**
+     * Attach to a shared memory segment that was created
+     * by another process.
+     * @param file The abstract file path that was used to create a
+     *             shared memory block.
+     */
+    public static SharedMemory attach(File file)
+    {
+        return null;
+    }
+
+    /**
+     * Remove shared memory segment associated with a {@code file}.
+     * <p>
+     * This function is only supported on platforms which support
+     * name-based shared memory segments.
+     * </p>
+     * @param file The abstract file path associated with shared memory
+     *             segment which needs to be removed.
+     */
+    public static boolean remove(File file)
+    {
+        return true;
+    }
+
+    /**
+     * Detach the shared memory segment from the system.
+     * <p>
+     * Detaching shared memory will remove reference to the shared
+     * memory.
+     * </p>
+     * <p><b>Warning:</b><br/>
+     * Any usage of the memory pointed by this shared memory
+     * segment after this call will probably crash the running JVM.
+     * </p>
+     */
+    public void detach()
+    {
+    }
+
+    /**
+     * Close and remove the shared memory segment from the system.
+     * <p>
+     * Closing shared memory will remove reference to the shared
+     * memory segment and remove it from the system. Actual removal
+     * will happen when the last {@code SharedMemory} object referencing
+     * the shared memory segment is closed or detached.
+     * </p>
+     * <p><b>Warning:</b><br/>
+     * Any usage of the memory pointed by this shared memory
+     * segment after this call will probably crash the running JVM.
+     * </p>
+     */
+    public void close()
+    {
+    }
+
+    /**
+     * Retrieve the length of a shared memory segment in bytes.
+     */
+    public long size()
+    {
+        return 0;
+    }
+
+    /**
+     * Retrieve new {@code Pointer} base address of the shared memory segment.
+     * <p>
+     * <b>Warning:</b><br/>This address is only usable within the callers
address
+     * space, since this API does not guarantee that other attaching
+     * processes will maintain the same address mapping.
+     * </p>
+     * @return Memory pointer.
+     */
+    public Pointer get()
+    {
+        return null;
+    }
+
+    /**
+     * Retrieve new @code Pointer}address of the shared memory segment.
+     * <p>
+     * <b>Warning:</b><br/>This address is only usable within the callers
address
+     * space, since this API does not guarantee that other attaching
+     * processes will maintain the same address mapping.
+     * </p>
+     * @param offset Offset in bytes from the begining of the shared memory.
+     * @param size Size to map.
+     * @return Memory pointer.
+     */
+    public Pointer get(long offset, long size)
+    {
+        return null;
+    }
+
+}
+

Propchange: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/SharedMemory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message