[libinline-java-perl] 369/398: new callback interface
Jonas Smedegaard
dr at jones.dk
Thu Feb 26 11:43:26 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to tag 0.55
in repository libinline-java-perl.
commit 39608d6f5ee76a21e5c17504bbb8f652fba614fe
Author: patrick_leb <>
Date: Sat Jan 21 14:32:52 2006 +0000
new callback interface
---
.../org/perl/inline/java/InlineJavaPerlCaller.java | 74 +++++++++++++++++-----
1 file changed, 59 insertions(+), 15 deletions(-)
diff --git a/Java/sources/org/perl/inline/java/InlineJavaPerlCaller.java b/Java/sources/org/perl/inline/java/InlineJavaPerlCaller.java
index 0948b3e..f59918e 100644
--- a/Java/sources/org/perl/inline/java/InlineJavaPerlCaller.java
+++ b/Java/sources/org/perl/inline/java/InlineJavaPerlCaller.java
@@ -143,7 +143,7 @@ public class InlineJavaPerlCaller {
ijc.Process() ;
return ijc.GetResponse() ;
}
- else{
+ else {
// Enqueue the callback into the creator thread's queue and notify it
// that there is some work for him.
ijc.ClearResponse() ;
@@ -158,24 +158,68 @@ public class InlineJavaPerlCaller {
}
+ public void OpenCallbackStream() throws InlineJavaException {
+ Thread t = Thread.currentThread() ;
+ if (! ijs.IsThreadPerlContact(t)){
+ throw new InlineJavaException("InlineJavaPerlCaller.OpenCallbackStream() can only be called by threads that communicate directly with Perl") ;
+ }
+
+ InlineJavaCallbackQueue q = GetQueue(t) ;
+ q.OpenCallbackStream() ;
+ }
+
+
+ /*
+ Blocks until either a callback arrives, timeout seconds has passed or the call is
+ interrupted by Interrupt?
+ */
+ public int WaitForCallback(double timeout) throws InlineJavaException {
+ Thread t = Thread.currentThread() ;
+ if (! ijs.IsThreadPerlContact(t)){
+ throw new InlineJavaException("InlineJavaPerlCaller.WaitForCallback() can only be called by threads that communicate directly with Perl") ;
+ }
+
+ InlineJavaCallbackQueue q = GetQueue(t) ;
+ if (timeout == 0.0){
+ // no wait
+ return q.GetSize() ;
+ }
+ else if (timeout == -1.0){
+ timeout = 0.0 ;
+ }
+
+ return q.WaitForCallback(timeout) ;
+ }
+
+
+ public boolean ProcessNextCallback() throws InlineJavaException, InlineJavaPerlException {
+ Thread t = Thread.currentThread() ;
+ if (! ijs.IsThreadPerlContact(t)){
+ throw new InlineJavaException("InlineJavaPerlCaller.ProcessNextCallback() can only be called by threads that communicate directly with Perl") ;
+ }
+
+ InlineJavaCallbackQueue q = GetQueue(t) ;
+ return q.ProcessNextCallback() ;
+ }
+
+
+ public void CloseCallbackStream() throws InlineJavaException {
+ InlineJavaCallbackQueue q = GetQueue(creator) ;
+ q.CloseCallbackStream() ;
+ }
+
+
public void StartCallbackLoop() throws InlineJavaException, InlineJavaPerlException {
Thread t = Thread.currentThread() ;
if (! ijs.IsThreadPerlContact(t)){
throw new InlineJavaException("InlineJavaPerlCaller.StartCallbackLoop() can only be called by threads that communicate directly with Perl") ;
}
-
+
InlineJavaCallbackQueue q = GetQueue(t) ;
- q.StartLoop() ;
- while (! q.IsLoopStopped()){
- InlineJavaUtils.debug(3, "waiting for callback request in " + t.getName() + "...") ;
- InlineJavaCallback ijc = q.WaitForCallback() ;
- InlineJavaUtils.debug(3, "waiting for callback request finished " + t.getName() + "...") ;
- InlineJavaUtils.debug(3, "processing callback request in " + t.getName() + "...") ;
- // The callback object can be null if the wait() is interrupted by StopCallbackLoop
- if (ijc != null){
- ijc.Process() ;
- ijc.NotifyOfResponse(t) ;
- }
+ InlineJavaUtils.debug(3, "starting callback loop for " + creator.getName() + " in " + t.getName()) ;
+ q.OpenCallbackStream() ;
+ while (q.IsStreamOpen()){
+ q.ProcessNextCallback() ;
}
}
@@ -183,8 +227,8 @@ public class InlineJavaPerlCaller {
public void StopCallbackLoop() throws InlineJavaException {
Thread t = Thread.currentThread() ;
InlineJavaCallbackQueue q = GetQueue(creator) ;
- InlineJavaUtils.debug(3, "interrupting callback loop for " + creator.getName() + " in " + t.getName()) ;
- q.StopLoop() ;
+ InlineJavaUtils.debug(3, "stopping callback loop for " + creator.getName() + " in " + t.getName()) ;
+ q.CloseCallbackStream() ;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libinline-java-perl.git
More information about the Pkg-perl-cvs-commits
mailing list