lib/ru/fe_misc.rb in openwferu-0.9.0 vs lib/ru/fe_misc.rb in openwferu-0.9.1
- old
+ new
@@ -1,6 +1,7 @@
#
+#--
# Copyright (c) 2006, John Mettraux, OpenWFE.org
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@@ -25,10 +26,11 @@
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
+#++
#
# $Id: definitions.rb 2725 2006-06-02 13:26:32Z jmettraux $
#
#
@@ -87,9 +89,54 @@
result = eval(code.to_s)
OpenWFEru::set_result(workitem, result) if result != nil
reply_to_parent(workitem)
+ end
+ end
+
+ #
+ # Triggers the first (and supposedly unique child of this expression)
+ # but never wait for its reply (lose it).
+ # A 'lose' expression never replies to its parent expression.
+ #
+ class LoseExpression < FlowExpression
+
+ def apply (workitem)
+ get_expression_pool.apply(children[0], workitem) \
+ if (@children and @children.length > 0)
+ end
+
+ def reply (workitem)
+ # does nothing at all
+ end
+ end
+
+ #
+ # This method triggers its child (in its own thread) and then
+ # forgets about it. It immediately replies to its parent expression.
+ #
+ class ForgetExpression < LoseExpression
+
+ def apply (workitem)
+
+ if (@children and @children.length > 0)
+
+ wi = workitem.dup
+
+ Thread.new do
+ begin
+ get_expression_pool.apply(@children[0], wi)
+ rescue Exception => e
+ lwarn do
+ "apply() failed to apply child to forget "+
+ OpenWFEru::exception_to_s(e)
+ end
+ end
+ end
+ end
+
+ reply_to_parent(wi)
end
end
end