lib/openwfe/worklist/storelocks.rb in openwferu-0.9.16 vs lib/openwfe/worklist/storelocks.rb in openwferu-0.9.17

- old
+ new

@@ -1,8 +1,8 @@ # #-- -# Copyright (c) 2007, John Mettraux, OpenWFE.org +# Copyright (c) 2007-2008, 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: # @@ -37,12 +37,12 @@ # # John Mettraux at openwfe.org # require 'thread' +require 'rufus/otime' require 'openwfe/contextual' -require 'openwfe/util/otime' module OpenWFE # @@ -85,11 +85,11 @@ @store = @store.new if @store.kind_of?(Class) self.application_context = application_context @lock_max_age = params[:lock_max_age] || DEFAULT_LOCK_MAX_AGE - @lock_max_age = OpenWFE::parse_time_string @lock_max_age + @lock_max_age = Rufus::parse_time_string @lock_max_age @locks = {} @lock_mutex = Mutex.new end @@ -131,10 +131,11 @@ # # Gets a workitem without locking it. # def get (key) + @store[key] end # # Removes a lock set on an item. @@ -182,34 +183,37 @@ # # Directly forwards the list_workitems() call to the wrapped store. # def list_workitems (workflow_instance_id=nil) + @store.list_workitems(workflow_instance_id) end # # Returns the count of workitems in the store. # def size + @store.size end # # Just calls the consume method of the underlying store. # def consume (workitem) + @store.consume workitem end # # Iterates over the workitems in the store. # # Doesn't care about any order for now. # def each (&block) # :yields: workitem, locked - return unless block + @store.each do |fei, workitem| block.call workitem, locked?(fei) end end @@ -245,9 +249,10 @@ # # Returns true if the object is locked # def locked? (key) + @locks[key] != nil end # # Will raise an exception if the object (designated via its key)