You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/09/12 12:53:55 UTC

svn commit: r814141 - /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java

Author: mturk
Date: Sat Sep 12 10:53:55 2009
New Revision: 814141

URL: http://svn.apache.org/viewvc?rev=814141&view=rev
Log:
Add callback support

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

Added: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java?rev=814141&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java (added)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Callback.java Sat Sep 12 10:53:55 2009
@@ -0,0 +1,56 @@
+/* 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;
+
+/**
+ * Callback interface.
+ * <p>
+ * Callbacks are called from the native code when a native operation
+ * requires the state introspection from the Java code. The Callback
+ * implementation receives the {@code opaque} data object that was
+ * registered during the callback initialisation stage.
+ * </p>
+ * <p>
+ * Native callback management code uses {@code WeakReference} for both
+ * the opaque data and callback object itself. This means that garbage
+ * collection may destroy those objects if they are referenced only
+ * by the native code. If this behaviour is not desirable make sure
+ * you hold the references to those objects.
+ * </p>
+ *
+ * @since Runtime 1.0
+ */
+public interface Callback
+{
+    /**
+     * Callback method.
+     * <p>
+     * If {@code callback} returns {@code zero} the operation continues.
+     * If negative value is returned the operation breaks. If positive
+     * value is returned the native part will decide what to do with this
+     * value and it depends on the implementation of the callback itself.
+     * </p>
+     *
+     * @param opaque Data passed to the callback at register time.
+     * @param status Native provided status call that informs about
+     *               the callback reason.
+     * @return Continuation state that defines
+     *         if the operation should continue or not.
+     */
+    public int callback(Object opaque, int status);
+
+}

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