simulavr-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Simulavr-devel] Call Back remove


From: Theodore A. Roth
Subject: Re: [Simulavr-devel] Call Back remove
Date: Tue, 4 Nov 2003 13:08:17 -0800 (PST)


On Tue, 4 Nov 2003, Keith Gudger wrote:

> Ted:
>
> I'm working on imlementing the SPI function.  This function uses a "timer"
> to count 8 (divided) clock ticks.  I was thinking that I'd "install" this
> clock callback everytime the user loads the SPDR, and "remove" it when it
> finished counting down.
>
> I don't, however, find any code for callback removal.  I found
> "callback_destroy", but that doesn't remove it from the callback list
> (which would be dangerous to do only that).  Do you know - does this code
> exist?  (I don't even find a "dlist_remove" function).

The removal of a callback depends on the value returned from the
callback function. From callback.h:

  typedef int (*CallBack_FP)( uint64_t time, AvrClass *data );

  enum _cb_ret_codes {
      CB_RET_RETAIN = 0, /* Give the callback in the list and run it again */
      CB_RET_REMOVE = 1, /* Remove callback from list */
  };

The core calls callback_list_execute_all() which calls dlist_iterator()
which executes all the callbacks and removes any callbacks from the list
that ask to be removed via the returned value.

>
> Am I on the right track here?  Thanks.

Essentially. Just install the callback, then, when the callback has seen
8 cycles, just return CB_RET_REMOVE and the callback is automagically
removed from the list.

Ted Roth




reply via email to

[Prev in Thread] Current Thread [Next in Thread]