annotate sched/sched_at.m @ 28:673b8e45d05a

Tidied up indentation.
author samer
date Sat, 19 Jan 2013 14:40:54 +0000
parents f7fb679637ff
children
rev   line source
samer@10 1 % sched_abs- Use one-shot timer to schedule action
samer@10 2 %
samer@10 3 % sched_abs:: timer, time, (timer, timer_event => void) => void.
samer@10 4 %
samer@10 5 % Can only be used on a stopped timer, whereas callback executes with
samer@10 6 % a running timer.
samer@10 7
samer@10 8 function x=sched_abs(f,T,nout)
samer@10 9 if nargin<3, nout=nargout(f); end
samer@10 10 rc=cell(1,nout);
samer@10 11 tim=timer('TimerFcn',@(t,e)timfn,'StopFcn',@stopfn,'StartDelay',quant(0.001,T-nows));
samer@10 12 start(tim);
samer@10 13 x=@()collect();
samer@10 14
samer@10 15 function timfn, [rc{:}]=f(); end
samer@10 16 function stopfn(t,e), timer_release(t); end
samer@10 17 function varargout=collect(),
samer@10 18 if isvalid(tim), wait(tim); end
samer@10 19 varargout=rc;
samer@10 20 end
samer@10 21 end