[Openmcl-devel] Timers...

Jon S. Anthony j-anthony at comcast.net
Thu Jun 4 14:50:28 UTC 2009


Hi Gary,

Thanks for the information.  On another note, mostly just curious, is
there any particular reason why CCL doesn't just supply an asynchronous
transfer of control timer construct?  It would seem that whatever
machinery is used for the timed semaphore would be a natural for this.
OK, I suppose I can just look this up in the code to see for myself...

/Jon


On Thu, 2009-06-04 at 01:49 -0600, Gary Byers wrote:
> This seems generally reasonable.  There's always a chance that the
> semaphore would have been seen to b signaled if only the timeout had
> been slightly longer, so the target thread might complete its work,
> signal the semaphore, and then get an interrupt.  Depending on the
> application, that may or may not be significant.
> 
> On Wed, 3 Jun 2009, Jon S. Anthony wrote:
> 
> > Hi,
> >
> > I'm porting a system to CCL and one bit I've come up to is a with-timer
> > capability.  Is something like this pretty much the "right" way to
> > achieve this in CCL?  I know about Dan Corkill's variant (in
> > "portable-threads"), but this seems a bit better.  Yes?  No?
> >
> >
> > #+ccl
> > (defun interrupt-timer (interruptable-process semaphore duration func)
> >  (let ((work-done (ccl:timed-wait-on-semaphore semaphore duration)))
> >    (when (not work-done)
> >      (ccl:process-interrupt
> >       interruptable-process
> >       func))))
> >
> > #+ccl
> > (defmacro with-timer ((seconds-available &body timeout-forms) &body
> > body)
> >  (with-gensyms (semaphore tag)
> >    `(let* ((,semaphore (ccl:make-semaphore))
> >            (,tag (gensym)))
> >       (ccl:process-run-function
> >        "timer-proc"
> >        #'interrupt-timer
> >        ccl:*current-process*
> >        ,semaphore ,seconds-available
> >        #'(lambda () (throw ,tag (progn , at timeout-forms))))
> >       (catch ,tag
> >         (unwind-protect
> >            (progn , at body)
> >           (ccl:signal-semaphore ,semaphore))) )))
> >
> >
> > _______________________________________________
> > Openmcl-devel mailing list
> > Openmcl-devel at clozure.com
> > http://clozure.com/mailman/listinfo/openmcl-devel
> >
> >




More information about the Openmcl-devel mailing list