Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Attributes and syntax extensions for the built-in timers #420

Open
@pdeligia

Description

Low-priority proposal. It would be nice to have attributes and syntax extensions that simplify using the new built-in timers.

For example, instead of the user having to explicitly handle a TimerElapsedEvent, they could use an attribute such as:

[OnTimeoutDoAction(nameof(HandleTimeoutForPing))]
class SomeState : MachineState { }

instead of:

[OnEventDoAction(typeof(TimerElapsedEvent), nameof(HandleTimeoutForPing))]
class SomeState : MachineState { }

Also, the HandleTimeoutForPing would now receive the TimerInfo as argument (instead of having to access the TimerElapsedEvent which would be internal.

void HandleTimeout(TimerInfo info) {
  ...
}

instead of:

void HandleTimeout() {
  var info = (this.ReceivedEvent as TimerElapsedEvent).Info;
  ...
}

This can be supported in the P# syntax on something like:

on timeout do HandleTimeout;

Metadata

Assignees

No one assigned

    Labels

    compilerFeature related to the compilerlanguage-designFeature related to the language designusabilityIssue or update regarding usability

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions