Getting somewhere, with the new schedulers, the TASK logic works now much better!

- Schedulers are stopped when the parent object is destroyed.
- Parent objects are garbage cleaned.
- Destructors are called.

Jippie! Results!!!
This commit is contained in:
FlightControl
2016-12-13 13:05:21 +01:00
parent e98814e8d4
commit 02d4bbf3ff
7 changed files with 15 additions and 12 deletions
+2 -2
View File
@@ -132,7 +132,7 @@ function BASE:_SetDestructor()
-- TODO: Okay, this is really technical... -- TODO: Okay, this is really technical...
-- When you set a proxy to a table to catch __gc, weak tables don't behave like weak... -- When you set a proxy to a table to catch __gc, weak tables don't behave like weak...
-- Therefore, I am parking this logic until I've properly discussed all this with the community. -- Therefore, I am parking this logic until I've properly discussed all this with the community.
--[[ --
local proxy = newproxy(true) local proxy = newproxy(true)
local proxyMeta = getmetatable(proxy) local proxyMeta = getmetatable(proxy)
@@ -147,7 +147,7 @@ function BASE:_SetDestructor()
-- table is about to be garbage-collected - then the __gc hook -- table is about to be garbage-collected - then the __gc hook
-- will be invoked and the destructor called -- will be invoked and the destructor called
rawset( self, '__proxy', proxy ) rawset( self, '__proxy', proxy )
--]] --
end end
--- This is the worker method to inherit from a parent class. --- This is the worker method to inherit from a parent class.
+6 -5
View File
@@ -69,7 +69,7 @@ function TIMER:AddSchedule( Scheduler, ScheduleFunction, ScheduleArguments, Star
self:T3( self.Schedule[Scheduler][self.CallID] ) self:T3( self.Schedule[Scheduler][self.CallID] )
self.Schedule[Scheduler][self.CallID].CallHandler = function( CallID ) self.Schedule[Scheduler][self.CallID].CallHandler = function( CallID )
self:F3( CallID ) self:F( CallID )
local ErrorHandler = function( errmsg ) local ErrorHandler = function( errmsg )
env.info( "Error in timer function: " .. errmsg ) env.info( "Error in timer function: " .. errmsg )
@@ -84,15 +84,16 @@ function TIMER:AddSchedule( Scheduler, ScheduleFunction, ScheduleArguments, Star
Scheduler = self.PersistentSchedulers[CallID] Scheduler = self.PersistentSchedulers[CallID]
end end
self:T3( { Scheduler = Scheduler } ) self:T( { Scheduler = Scheduler } )
if Scheduler then if Scheduler then
local Schedule = self.Schedule[Scheduler][CallID] local Schedule = self.Schedule[Scheduler][CallID]
self:T3( { Schedule = Schedule } ) self:T( { Schedule = Schedule } )
local ScheduleObject = Scheduler.TimeEventObject local ScheduleObject = Scheduler.TimeEventObject
--local ScheduleObjectName = Scheduler.TimeEventObject:GetNameAndClassID()
local ScheduleFunction = Schedule.Function local ScheduleFunction = Schedule.Function
local ScheduleArguments = Schedule.Arguments local ScheduleArguments = Schedule.Arguments
local Start = Schedule.Start local Start = Schedule.Start
@@ -127,7 +128,7 @@ function TIMER:AddSchedule( Scheduler, ScheduleFunction, ScheduleArguments, Star
( Randomize * Repeat / 2 ) ( Randomize * Repeat / 2 )
) + ) +
0.01 0.01
self:T( { ScheduleArguments, "Repeat:", CurrentTime, ScheduleTime } ) self:T3( { ScheduleArguments, "Repeat:", CurrentTime, ScheduleTime } )
return ScheduleTime -- returns the next time the function needs to be called. return ScheduleTime -- returns the next time the function needs to be called.
else else
timer.removeFunction( ScheduleID ) timer.removeFunction( ScheduleID )
@@ -138,7 +139,7 @@ function TIMER:AddSchedule( Scheduler, ScheduleFunction, ScheduleArguments, Star
ScheduleID = nil ScheduleID = nil
end end
else else
self:E( "Scheduled obscolete call ..." ) --self:E( "Scheduled obscolete call for CallID: " .. CallID )
end end
return nil return nil
+5 -3
View File
@@ -64,9 +64,11 @@ Include.File( "Tasking/Task_A2G" )
--- Declare the event dispatcher based on the EVENT class --- Declare the event dispatcher based on the EVENT class
_EVENTDISPATCHER = EVENT:New() -- Core.Event#EVENT _EVENTDISPATCHER = EVENT:New() -- Core.Event#EVENT
--- Declare the main database object, which is used internally by the MOOSE classes.
_DATABASE = DATABASE:New() -- Database#DATABASE
--- Declare the timer dispatcher based on the TIMER class --- Declare the timer dispatcher based on the TIMER class
_TIMERDISPATCHER = TIMER:New() -- Core.Timer#TIMER _TIMERDISPATCHER = TIMER:New() -- Core.Timer#TIMER
--- Declare the main database object, which is used internally by the MOOSE classes.
_DATABASE = DATABASE:New() -- Database#DATABASE
@@ -1,5 +1,5 @@
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20161209_1413' ) env.info( 'Moose Generation Timestamp: 20161213_1239' )
local base = _G local base = _G
+1 -1
View File
@@ -1,5 +1,5 @@
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' ) env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
env.info( 'Moose Generation Timestamp: 20161209_1413' ) env.info( 'Moose Generation Timestamp: 20161213_1239' )
local base = _G local base = _G