diff --git a/default/proto.lua b/default/proto.lua index a79dec4..2844c9d 100644 --- a/default/proto.lua +++ b/default/proto.lua @@ -32,6 +32,7 @@ proto.checkgauge = init = true, maxDelays = true, maxProcesses = true, + mindelay = true, onAttrib = true, onCreate = true, onModify = true, @@ -295,3 +296,8 @@ proto.prepare = function check( config, gauge, '', level + 1 ) end + +-- +-- Default minimum 1 second delay to do anything +-- +proto.mindelay = 1 diff --git a/mantle/delay.lua b/mantle/delay.lua index 6dd3b2e..2eef985 100644 --- a/mantle/delay.lua +++ b/mantle/delay.lua @@ -32,7 +32,7 @@ local mt = { } local k_nt = { } -local assignAble = +local assignable = { dpos = true, etype = true, @@ -63,7 +63,7 @@ mt.__newindex = function k, -- key value to assign to v -- value to assign ) - if not assignAble[ k ] + if not assignable[ k ] then error( 'Cannot assign new key "' .. k .. '" to Delay' ) end @@ -134,20 +134,20 @@ local function new -- move destination ) local delay = - { - blockedBy = blockedBy, - setActive = setActive, - wait = wait, - [ k_nt ] = - { - etype = etype, - sync = sync, - alarm = alarm, - path = path, - path2 = path2, - status = 'wait' - }, - } + { + blockedBy = blockedBy, + setActive = setActive, + wait = wait, + [ k_nt ] = + { + etype = etype, + sync = sync, + alarm = alarm, + path = path, + path2 = path2, + status = 'wait' + }, + } setmetatable( delay, mt ) diff --git a/mantle/inlet.lua b/mantle/inlet.lua index 7678d9b..4f47037 100644 --- a/mantle/inlet.lua +++ b/mantle/inlet.lua @@ -249,7 +249,7 @@ local eventFields = event ) return( - e2d[event].sync.source + e2d[ event ].sync.source .. ( string.match( getPath( event ), '^(.*/)[^/]+/?' ) or '' @@ -362,6 +362,17 @@ local eventMeta = -- local eventListFields = { + -- + -- Returns a copy of the configuration as called by sync. + -- But including all inherited data and default values. + -- + config = function + ( + dlist + ) + return dlist.sync.config + end, + -- -- Returns true if the sync this event list belongs to is stopped -- @@ -380,7 +391,7 @@ local eventListFields = local eventListFuncs = { -- - -- Returns a list of paths of all events in list. + -- Returns a list of paths of all events in this list. -- getPaths = function ( @@ -431,9 +442,6 @@ local eventListMeta = ) if field == 'isList' then return true end - -- FIXME make an actual field - if field == 'config' then return e2d[ elist ].sync.config end - local f = eventListFields[ field ] if f then return f( e2d[ elist ] ) end diff --git a/mantle/sync.lua b/mantle/sync.lua index 23c854b..a334ae2 100644 --- a/mantle/sync.lua +++ b/mantle/sync.lua @@ -133,29 +133,23 @@ local function collect error( 'collecting a non-active process' ) end - local rc = self.config.collect( - InletFactory.d2e( delay ), - exitcode - ) + local rc = + self.config.collect( + InletFactory.d2e( delay ), + exitcode + ) if rc == 'die' then log( 'Error', 'Critical exitcode.' ) - terminate( -1 ) elseif rc ~= 'again' then -- if its active again the collecter restarted the event removeDelay( self, delay ) - log( - 'Delay', - 'Finish of ', - delay.etype, - ' on ', - self.source,delay.path, - ' = ', - exitcode + 'Delay', 'Finish of ', delay.etype, ' on ', + self.source,delay.path, ' = ', exitcode ) else -- sets the delay on wait again @@ -477,13 +471,13 @@ local function getAlarm ( self ) + -- first checks if more processes could be spawned if self.stopped or #self.processes >= self.config.maxProcesses then return false end - -- first checks if more processes could be spawned -- finds the nearest delay waiting to be spawned for _, d in self.delays:qpairs( ) do @@ -862,6 +856,19 @@ local function new error( 'delay must be a number and >= 0', 2 ) end + -- this is written in a negated way + -- since this way it will raise any issues of mindelay or delay + -- not being numbers as well + + if not ( config.mindelay >= config.delay ) + then + error( + 'mindelay (= '..config.mindelay.. ') must be larger '.. + 'or equal than delay (= '..config.delay..')', + level + ) + end + if config.filterFrom then if not s.filters then s.filters = Filters.new( ) end diff --git a/mantle/syncmaster.lua b/mantle/syncmaster.lua index 74a570e..dc69c8b 100644 --- a/mantle/syncmaster.lua +++ b/mantle/syncmaster.lua @@ -358,7 +358,7 @@ end -- SyncMaster = { - add = add, -- FIXME forward through metatable + add = add, remove = remove, getRound = getRound, concerns = concerns,