Re: Task API

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

Robert Craig wrote:
> 
> I haven't decided.
> It could be two calls like: task_clock_stop() ... task_clock_resume()
> Or it could be one call: task_clock_shift(atom seconds)
> where the application would keep track of how many
> seconds went by while the user was on the phone,
> and tell me to shift the scheduler's clock accordingly.
> 

Well in the regular Language War game, you use the second method. The game seems
to run fine with or without it though. Why is "bad" not having it?

What is task_clock_shift(atom seconds) suppost to do? Is it suppost to
re-schedule all the suspended & active "real-time" tasks when the program
resumes?

I made a routine:

global function task_schedule_(integer i, object x)
    task_schedule(i, x)
    ? x  -- remove this
    return x
end function

global procedure task_shift_times(object SchedArgs, atom seconds)
    sequence tasks
    tasks = task_list() -- defined in task.e
    for i = 1 to length(tasks) do
	if length(SchedArgs[i]) = 2 then
	    ignore(task_schedule_(tasks[i], {
	    SchedArgs[i][1] + seconds,
	    SchedArgs[i][2] + seconds}))
	end if
    end for
end procedure


I also made an example program that waits for the user to press 'q', and counts
how long the program has been waiting.

Output:
-----------------------------------
Original task_schedule() arguments:
Task 1: {1,3}
Task 2: {4,6}
Task 3: {7,9}

Press 'q' to resume
Seconds waited: 12.85

New task_schedule() arguments:
Task 1: {13.85,15.85}
Task 2: {16.85,18.85}
Task 3: {19.85,21.85}
-----------------------------------

Is that what it's suppost to do?
Does this apply to time-shared tasks too?


Regards,
Vincent

----------------------------------------------
     ___	      __________      ___
    /__/\            /__________\    |\ _\
    \::\'\          //::::::::::\\   |'|::|
     \::\'\        //:::_::::_:::\\  |'|::|
      \::\'\      //::/  |::|  \::\\ |'|::|
       \::\'\    //::/   |::|   \::\\|'|::|
        \::\'\__//::/    |::|    \::\|'|::|
         \::\','/::/     |::|     \::\\|::|
          \::\_/::/      |::|      \::\|::|
           \::,::/       |::|       \:::::|
            \___/        |__|        \____|

 	                 .``.
		         ',,'

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

Search



Quick Links

User menu

Not signed in.

Misc Menu