Multitasking bug: cannot create task if procedure is in include file

new topic     » topic index » view thread      » older message » newer message

If a procedure is in an include file, then create_task() gives an error:

test_timer.ex:16 
specify the routine id of a procedure, not a function or type 

Have I done something wrong? The program works perfectly if entire include file is copied and pasted to the main test_timer.ex file:

test_timer.ex

include timer.e 
 
clear_screen() 
puts(1, "Main task started\n") 
puts(1, "Enter q to quit.\n") 
 
atom t1 
atom id = routine_id("timer_display") 
t1 = task_create(id, {1, 50}) 
task_schedule(t1, {.5, .6}) 
 
while 1 do 
    if get_key() = 'q' then 
        exit 
    end if 
    task_yield() 
end while 
 
puts(1, "Main task stopped.\n") 

timer.e

-- Display a counter from 0 seconds. 
-- 
 
include std/datetime.e 
include std/math.e 
 
 
    object g_start_time = now() 
 
 
    procedure timer_init() 
        g_start_time = now() 
    end procedure 
 
 
    function split_timer(atom l) 
    -- 
    -- l is no. of seconds, split it into {mm, ss} 
    -- 
        return {trunc(l/60), remainder(l, 60)} 
    end function 
 
 
    procedure timer_display(integer row, integer col) 
    -- 
    -- Display timer in mm:dd form on screen at location row,col 
    -- May call timer_init() first to establish start time 
    -- although start time is defaulted to program load time. 
    -- 
        object x 
 
        -- 
        -- This is intended to be multitask 
        -- 
        while 1 do 
            x = split_timer(diff(g_start_time, now())) 
            position(row, col) 
            printf(1, "%02d:%02d\n", {x[1], x[2]}) 
 
            task_yield() 
        end while 
    end procedure 

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu