pub struct Event {
name: String,
cls: *mut ConfClass,
flags: EventClassFlag,
event_class: *mut EventClass,
}
Expand description
Simplified event management mechanism using dynamic dispatch to circumvent complex trait requirements due to difference in callback specification and post time when using the canonical SIMICS APIs
Fields§
§name: String
The name of the event. This should identify the event uniquely.
cls: *mut ConfClass
The class the event will be posted for. This should be the class that is posting the
events, not the class the events are posting on. For example, if you are implementing
a module, cls
should be the main class in your module.
flags: EventClassFlag
Flags of the event. Should either be 0 (the default), which indicates the event should not
be saved, or [simics::api::sys::Sim_EC_Notsaved
] which indicates this may not be saved
in the configuration.
event_class: *mut EventClass
Implementations§
source§impl Event
impl Event
sourcepub fn event_class(&self) -> *mut EventClass
pub fn event_class(&self) -> *mut EventClass
Return the class of this event
sourcepub fn post_time<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
seconds: f64,
callback: F,
) -> Result<()>
pub fn post_time<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, seconds: f64, callback: F, ) -> Result<()>
An event of evclass for object obj is posted on clock to occur at a given point in the future. The user_data will be associated with the event. The clock is the object that should be used for keeping track of time for the event. It can be a processor or an instance of the clock class.
If a configuration class was specified when evclass was registered, then obj must be an instance of that class.
The expiration point can be specified in seconds, cycles or steps by using the appropriate call, and these values are relative to the current state. Events that need to run synchronized (Sim_EC_Machine_Sync) can only be posted in seconds or cycles, not steps, since synchronization can only be perform in virtual time.
Note: Events posted with SIM_event_post_cycle are posted at a certain point in time based on the clock’s current frequency, not at a certain clock cycle. The difference is significant if the frequency of the clock object can change dynamically.
§Arguments
obj
- The object the event is being posted onclock
- The clock whose time this event is being posted forseconds
- The number of seconds until this event expirescallback
- Callback to run for this event
§Context
Cell Context
sourcepub fn cancel_time(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
) -> Result<()>
pub fn cancel_time( &self, obj: *mut ConfObject, clock: *mut ConfObject, ) -> Result<()>
All unexpired evclass events posted for obj on clock for which pred returns nonzero will be cancelled and their destructor methods (if any) called. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), all evclass events for obj on clock will be cancelled.
There are separate calls for events posted at a point in time (cycle or seconds) and on a specific step.
§Arguments
obj
- The object the event was posted onclock
- The clock the event to cancel was posted on
§Context
Cell Context
sourcepub fn cancel_time_filter<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
filter: Option<F>,
) -> Result<()>
👎Deprecated: Filter function will not be freed. This will lead to memory leaks.
pub fn cancel_time_filter<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, filter: Option<F>, ) -> Result<()>
All unexpired evclass events posted for obj on clock for which pred returns nonzero will be cancelled and their destructor methods (if any) called. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), all evclass events for obj on clock will be cancelled.
There are separate calls for events posted at a point in time (cycle or seconds) and on a specific step.
§Arguments
obj
- The object the event was posted onclock
- The clock the event to cancel was posted onfilter
- The filter function. Note that there is a limitation currently which does not allow this filter function to be freed once it is boxed, which can lead to memory leaks, so this method is deprecated as a warning.
§Context
Cell Context
sourcepub fn post_step<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
steps: PcStep,
callback: F,
) -> Result<()>
pub fn post_step<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, steps: PcStep, callback: F, ) -> Result<()>
An event of evclass for object obj is posted on clock to occur at a given point in the future. The user_data will be associated with the event. The clock is the object that should be used for keeping track of time for the event. It can be a processor or an instance of the clock class.
If a configuration class was specified when evclass was registered, then obj must be an instance of that class.
The expiration point can be specified in seconds, cycles or steps by using the appropriate call, and these values are relative to the current state. Events that need to run synchronized (Sim_EC_Machine_Sync) can only be posted in seconds or cycles, not steps, since synchronization can only be perform in virtual time.
Note: Events posted with SIM_event_post_cycle are posted at a certain point in time based on the clock’s current frequency, not at a certain clock cycle. The difference is significant if the frequency of the clock object can change dynamically.
§Arguments
obj
- The object the event is being posted onclock
- The clock whose time this event is being posted forsteps
- The number of seconds until this event expirescallback
- Callback to run for this event
§Context
Cell Context
sourcepub fn cancel_step(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
) -> Result<()>
pub fn cancel_step( &self, obj: *mut ConfObject, clock: *mut ConfObject, ) -> Result<()>
All unexpired evclass events posted for obj on clock for which pred returns nonzero will be cancelled and their destructor methods (if any) called. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), all evclass events for obj on clock will be cancelled.
There are separate calls for events posted at a point in time (cycle or seconds) and on a specific step.
§Arguments
obj
- The object the event was posted onclock
- The clock the event to cancel was posted on
§Context
Cell Context
sourcepub fn cancel_step_filter<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
filter: Option<F>,
) -> Result<()>
👎Deprecated: Filter function will not be freed. This will lead to memory leaks.
pub fn cancel_step_filter<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, filter: Option<F>, ) -> Result<()>
All unexpired evclass events posted for obj on clock for which pred returns nonzero will be cancelled and their destructor methods (if any) called. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), all evclass events for obj on clock will be cancelled.
There are separate calls for events posted at a point in time (cycle or seconds) and on a specific step.
§Arguments
obj
- The object the event was posted onclock
- The clock the event to cancel was posted onfilter
- The filter function. Note that there is a limitation currently which does not allow this filter function to be freed once it is boxed, which can lead to memory leaks, so this method is deprecated as a warning.
§Context
Cell Context
sourcepub fn post_cycle<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
cycles: Cycles,
callback: F,
) -> Result<()>
pub fn post_cycle<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, cycles: Cycles, callback: F, ) -> Result<()>
An event of evclass for object obj is posted on clock to occur at a given point in the future. The user_data will be associated with the event. The clock is the object that should be used for keeping track of time for the event. It can be a processor or an instance of the clock class.
If a configuration class was specified when evclass was registered, then obj must be an instance of that class.
The expiration point can be specified in seconds, cycles or steps by using the appropriate call, and these values are relative to the current state. Events that need to run synchronized (Sim_EC_Machine_Sync) can only be posted in seconds or cycles, not steps, since synchronization can only be perform in virtual time.
Note: Events posted with SIM_event_post_cycle are posted at a certain point in time based on the clock’s current frequency, not at a certain clock cycle. The difference is significant if the frequency of the clock object can change dynamically.
§Arguments
obj
- The object the event is being posted onclock
- The clock whose time this event is being posted forcycles
- The number of seconds until this event expirescallback
- Callback to run for this event
§Context
Cell Context
sourcepub fn find_next_time(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
) -> Result<f64>
pub fn find_next_time( &self, obj: *mut ConfObject, clock: *mut ConfObject, ) -> Result<f64>
Return the number of cycles/seconds/steps to the first event of evclass of obj posted on clock for which pred is true, or −1 if no event matched. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), the first evclass event for obj on clock will be used.
There are separate calls of events posted at a point in time (cycle or seconds) and on a specific step. Note that the return value of SIM_event_find_next_cycle is only a preliminary estimate; the number of remaining cycles will change if the clock’s frequency changes dynamically. To handle dynamically changing clock frequencies correctly, subscribe to the frequency changes via the clock’s simple_dispatcher interface.
§Arguments
clock
- The clock for the posted eventobj
- The object posted on
§Return Value
If found, the cycle number the event will next trigger on
§Context
Cell Context
sourcepub fn find_next_time_filter<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
filter: F,
) -> Result<f64>
pub fn find_next_time_filter<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, filter: F, ) -> Result<f64>
Return the number of cycles/seconds/steps to the first event of evclass of obj posted on clock for which pred is true, or −1 if no event matched. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), the first evclass event for obj on clock will be used.
There are separate calls of events posted at a point in time (cycle or seconds) and on a specific step. Note that the return value of SIM_event_find_next_cycle is only a preliminary estimate; the number of remaining cycles will change if the clock’s frequency changes dynamically. To handle dynamically changing clock frequencies correctly, subscribe to the frequency changes via the clock’s simple_dispatcher interface.
§Arguments
clock
- The clock for the posted eventobj
- The object posted onfilter
- A function to filter objects by returning true or false
§Return Value
If found, the cycle number the event will next trigger on
§Context
Cell Context
sourcepub fn find_next_cycle(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
) -> Result<Cycles>
pub fn find_next_cycle( &self, obj: *mut ConfObject, clock: *mut ConfObject, ) -> Result<Cycles>
Return the number of cycles/seconds/steps to the first event of evclass of obj posted on clock for which pred is true, or −1 if no event matched. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), the first evclass event for obj on clock will be used.
There are separate calls of events posted at a point in time (cycle or seconds) and on a specific step. Note that the return value of SIM_event_find_next_cycle is only a preliminary estimate; the number of remaining cycles will change if the clock’s frequency changes dynamically. To handle dynamically changing clock frequencies correctly, subscribe to the frequency changes via the clock’s simple_dispatcher interface.
§Arguments
clock
- The clock for the posted eventobj
- The object posted on
§Return Value
If found, the cycle number the event will next trigger on
§Context
Cell Context
sourcepub fn find_next_cycle_filter<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
filter: F,
) -> Result<Cycles>
pub fn find_next_cycle_filter<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, filter: F, ) -> Result<Cycles>
Return the number of cycles/seconds/steps to the first event of evclass of obj posted on clock for which pred is true, or −1 if no event matched. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), the first evclass event for obj on clock will be used.
There are separate calls of events posted at a point in time (cycle or seconds) and on a specific step. Note that the return value of SIM_event_find_next_cycle is only a preliminary estimate; the number of remaining cycles will change if the clock’s frequency changes dynamically. To handle dynamically changing clock frequencies correctly, subscribe to the frequency changes via the clock’s simple_dispatcher interface.
§Arguments
clock
- The clock for the posted eventobj
- The object posted onfilter
- A function to filter objects by returning true or false
§Return Value
If found, the cycle number the event will next trigger on
§Context
Cell Context
sourcepub fn find_next_step(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
) -> Result<PcStep>
pub fn find_next_step( &self, obj: *mut ConfObject, clock: *mut ConfObject, ) -> Result<PcStep>
Return the number of cycles/seconds/steps to the first event of evclass of obj posted on clock for which pred is true, or −1 if no event matched. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), the first evclass event for obj on clock will be used.
There are separate calls of events posted at a point in time (cycle or seconds) and on a specific step. Note that the return value of SIM_event_find_next_cycle is only a preliminary estimate; the number of remaining cycles will change if the clock’s frequency changes dynamically. To handle dynamically changing clock frequencies correctly, subscribe to the frequency changes via the clock’s simple_dispatcher interface.
§Arguments
clock
- The clock for the posted eventobj
- The object posted on
§Return Value
If found, the cycle number the event will next trigger on
§Context
Cell Context
sourcepub fn find_next_step_filter<F>(
&self,
obj: *mut ConfObject,
clock: *mut ConfObject,
filter: F,
) -> Result<PcStep>
pub fn find_next_step_filter<F>( &self, obj: *mut ConfObject, clock: *mut ConfObject, filter: F, ) -> Result<PcStep>
Return the number of cycles/seconds/steps to the first event of evclass of obj posted on clock for which pred is true, or −1 if no event matched. pred will be called with the data associated with the event and the supplied match_data. If pred is null (None in Python), the first evclass event for obj on clock will be used.
There are separate calls of events posted at a point in time (cycle or seconds) and on a specific step. Note that the return value of SIM_event_find_next_cycle is only a preliminary estimate; the number of remaining cycles will change if the clock’s frequency changes dynamically. To handle dynamically changing clock frequencies correctly, subscribe to the frequency changes via the clock’s simple_dispatcher interface.
§Arguments
clock
- The clock for the posted eventobj
- The object posted onfilter
- A function to filter objects by returning true or false
§Return Value
If found, the cycle number the event will next trigger on
§Context
Cell Context
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Event
impl RefUnwindSafe for Event
impl !Send for Event
impl !Sync for Event
impl Unpin for Event
impl UnwindSafe for Event
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)