notify statement

notify(name, value) Command Documentation

The notify(name, value) command is used to send a notification with an associated value, signaling any code waiting for this notification using the wait(name, timeout) function. This mechanism enables inter-process communication by allowing one part of a program to inform another part of specific events or data conditions.

Structure of the notify Command

Components:

  1. name (String Literal): Specifies the name of the notification being sent. It must be a string literal that matches the name used in the corresponding wait function to establish a connection between the sender and receiver.
  2. value (Data): The data or message to be sent with the notification. This can be any data type supported by the language or system, providing information to the receiver, if NIL is used the receiver will not be able to easily distinguish between notification and a timeout.

Simple Example

    // Code block for notication. see wait documentation sending a value to stop the blink task

    result = 23;

    notify(“blink”, result);  // Notify with result as data

Explanation:

  • Notification Sendnotify("blink", result); sends a notification identified by the name “blink” and carries the computational result as the value.
  • Synchronization: This mechanism connects the notifying producer with any waiting consumers, ensuring data is passed as designed upon signaling.

Practical Use

  • Inter-process Communication: Use notify and wait to communicate and transfer data between r processes, ensuring that actions are coordinated according to the events or states of the application.

Considerations

  • String Literal Requirement: The name parameter in notify must be a string literal that precisely matches the string used in wait to ensure correct delivery and reception of notifications.
  • Value Propagation: Ensure the value provided serves the intended receiver’s needs and adheres to any protocol or expected data format for your application.

The notify(name, value) command, together with wait(name, timeout), establishes a robust framework for synchronizing operations and exchanging data between disparate parts of an application, supporting real-time data flow and responsive programming models.