Vuo  1.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Typedefs | Functions | Variables
VuoRuntime.cc File Reference

Description

VuoRuntime implementation.

Typedefs

typedef void(* VuoCompositionFiniCallback )(void)
 Callback prototype.
 
typedef std::list
< VuoCompositionFiniCallback
VuoCompositionFiniCallbackListType
 Type for fini callback list.
 

Functions

static void stopComposition (bool isBeingReplaced, int timeoutInSeconds)
 This function is called when the composition receives a stop request (VuoControlRequestCompositionStop), or when the a node or library requests a clean shutdown (VuoStopComposition).
 
void vuoStopComposition (void)
 Nodes/libraries can call this function (via its wrapper, VuoStopComposition) to initiate a clean shutdown of the composition.
 
char * getInputPortString (char *portIdentifier, bool shouldUseInterprocessSerialization)
 Returns a string representation of the input port's current value.
 
char * getOutputPortString (char *portIdentifier, bool shouldUseInterprocessSerialization)
 Returns a string representation of the output port's current value.
 
static char * getInputPortSummary (char *portIdentifier)
 Returns a summary of the input port's current value.
 
static char * getOutputPortSummary (char *portIdentifier)
 Returns a summary of the output port's current value.
 
static void vuoControlReplySend (enum VuoControlReply reply, zmq_msg_t *messages, unsigned int messageCount)
 This function may only be called on dispatch queue VuoControlQueue.
 
void vuoTelemetrySend (enum VuoTelemetry type, zmq_msg_t *messages, unsigned int messageCount)
 This function may be called from any thread.
 
void vuoInit (int argc, char **argv)
 Parses command-line arguments, then calls vuoInitInProcess().
 
char * VuoRuntime_mergeEnumDetails (string type, char *details)
 If type is an enum, merges the allowed enum values into details and returns it (caller responsible for freeing).
 
void VuoRuntime_watchdog (int timeoutInSeconds)
 If the composition is not stopped within the timeout, kills this process.
 
void vuoInitInProcess (void *_ZMQContext, const char *controlURL, const char *telemetryURL, bool _isPaused, pid_t _runnerPid, int runnerPipe, bool continueIfRunnerDies, bool trialRestrictionsEnabled, void *_VuoCompositionFiniCallbackList)
 Sets up ZMQ control and telemetry sockets, then calls the generated function vuoSetup().
 
void sendNodeExecutionStarted (char *nodeIdentifier)
 Constructs and sends a message on the telemetry socket, indicating that a node has started execution.
 
void sendNodeExecutionFinished (char *nodeIdentifier)
 Constructs and sends a message on the telemetry socket, indicating that a node has finished execution.
 
void sendInputPortsUpdated (char *portIdentifier, bool receivedEvent, bool receivedData, char *portDataSummary)
 Constructs and sends a message on the telemetry socket, indicating that an input port has received an event or data.
 
void sendOutputPortsUpdated (char *portIdentifier, bool sentData, char *portDataSummary)
 Constructs and sends a message on the telemetry socket, indicating that an output port has transmitted or fired an event.
 
void sendPublishedOutputPortsUpdated (char *portIdentifier, bool sentData, char *portDataSummary)
 Constructs and sends a message on the telemetry socket, indicating that a published output port has transmitted an event.
 
void sendEventDropped (char *portIdentifier)
 Constructs and sends a message on the telemetry socket, indicating that a trigger port has dropped an event.
 
void sendError (const char *message)
 Constructs and sends a message on the telemetry socket, indicating that an uncaught error has occurred.
 
bool vuoShouldSendPortDataTelemetry (const char *portIdentifier)
 Returns true if telemetry containing the port data summary should be sent for this port.
 
char * vuoSerializeTelemetryState (void)
 Serializes the variables controlling telemetry-sending to a JSON-formatted string.
 
void vuoUnserializeTelemetryState (char *serialized)
 Unserializes the variables controlling telemetry-sending from a JSON-formatted string.
 
void vuoAddCompositionFiniCallback (VuoCompositionFiniCallback fini)
 Registers a callback to be invoked when the composition is shutting down, after all nodes have been fini'd.
 
void vuoFini (void)
 Cleans up composition execution: closes the ZMQ sockets and dispatch source and queues.
 
void vuoSetup (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void vuoCleanup (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void vuoInstanceInit (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void vuoInstanceFini (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void vuoInstanceTriggerStart (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void vuoInstanceTriggerStop (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void vuoSetInputPortValue (char *portIdentifier, char *valueAsString)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void fireTriggerPortEvent (char *portIdentifier)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char * vuoGetPortValue (char *portIdentifier, int serializationType)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
unsigned int getPublishedInputPortCount (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
unsigned int getPublishedOutputPortCount (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char ** getPublishedInputPortNames (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char ** getPublishedOutputPortNames (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char ** getPublishedInputPortTypes (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char ** getPublishedOutputPortTypes (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char ** getPublishedInputPortDetails (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char ** getPublishedOutputPortDetails (void)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void firePublishedInputPortEvent (char *name)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void setPublishedInputPortValue (char *portIdentifier, char *valueAsString)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char * getPublishedInputPortValue (char *portIdentifier, int shouldUseInterprocessSerialization)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
char * getPublishedOutputPortValue (char *portIdentifier, int shouldUseInterprocessSerialization)
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 
void VuoHeap_report ()
 Sends a telemetry error with information about any objects remaining in the reference counting table.
 

Variables

bool hasZMQConnection = false
 True if the ZMQControl and ZMQTelemetry sockets are connected to something.
 
static dispatch_queue_t VuoControlQueue
 Dispatch queue for protecting access to the ZMQControl socket.
 
static dispatch_queue_t VuoTelemetryQueue
 Dispatch queue for protecting access to the ZMQTelemetry socket.
 
static void * ZMQContext
 The context used to initialize sockets.
 
static void * ZMQControl
 The control socket. Use only on VuoControlQueue.
 
static void * ZMQSelfReceive = 0
 Used to break out of a ZMQControl poll.
 
static void * ZMQSelfSend = 0
 Used to break out of a ZMQControl poll.
 
static void * ZMQTelemetry = 0
 The telemetry socket. Use only on VuoTelemetryQueue.
 
static bool hasBeenUnpaused
 True if node execution was unpaused initially, or if it has since been unpaused.
 
bool isStopped
 True if composition execution has stopped.
 
bool isStopRequested
 True if vuoStopComposition() has been called.
 
static dispatch_source_t telemetryTimer
 Timer for sending telemetry messages.
 
static dispatch_source_t controlTimer
 Timer for receiving control messages.
 
static dispatch_source_t waitForStopTimer = NULL
 Timer for checking if the runner will stop the composition.
 
static dispatch_semaphore_t telemetryCanceledSemaphore
 Signaled when telemetry events are no longer being processed.
 
static dispatch_semaphore_t controlCanceledSemaphore
 Signaled when control events are no longer being processed.
 
static dispatch_semaphore_t waitForStopCanceledSemaphore
 Signaled when no longer checking if the runner will stop the composition.
 
static bool isSendingAllTelemetry = false
 True if all telemetry should be sent.
 
static bool isSendingEventTelemetry = false
 True if all telemetry about events (not including data) should be sent.
 
static set< string > portsSendingDataTelemetry
 Port identifiers for which data-and-event telemetry should be sent.
 
pid_t VuoApp_runnerPid = 0
 Process ID of the runner that started the composition.
 
VuoCompositionFiniCallbackListTypeVuoCompositionFiniCallbackList
 Fini callbacks to invoke upon composition shutdown. Non-static, so that VuoCompositionLoader can fetch and restore it during live-coding reloads.
 
static dispatch_queue_t VuoCompositionFiniCallbackQueue = NULL
 Serializes access to the list of fini callbacks.
 
static dispatch_queue_t VuoCompositionStopQueue = NULL
 Ensures stops happen serially.
 
static bool wasStopCompositionCalled = false
 Prevents the composition from being finalized twice.
 
bool isPaused
 True if node execution is currently paused.
 
dispatch_group_t vuoTriggerWorkersScheduled
 Keeps track of trigger workers that have been scheduled but have not yet launched an event into the composition.
 
char * compositionDiff
 Differences between the old and new composition, when replacing compositions for live coding.
 
void vuoInitWorkerThreadPool (void)
 Sets up the pool of worker threads.
 
void vuoFiniWorkerThreadPool (void)
 Cleans up the pool of worker threads.
 

Typedef Documentation

typedef void(* VuoCompositionFiniCallback)(void)

Callback prototype.

Type for fini callback list.

Function Documentation

void firePublishedInputPortEvent ( char *  name)

Sends a telemetry error with information about any objects remaining in the reference counting table.

void fireTriggerPortEvent ( char *  portIdentifier)

Sends a telemetry error with information about any objects remaining in the reference counting table.

char * getInputPortString ( char *  portIdentifier,
bool  shouldUseInterprocessSerialization 
)

Returns a string representation of the input port's current value.

char * getInputPortSummary ( char *  portIdentifier)
static

Returns a summary of the input port's current value.

char * getOutputPortString ( char *  portIdentifier,
bool  shouldUseInterprocessSerialization 
)

Returns a string representation of the output port's current value.

char * getOutputPortSummary ( char *  portIdentifier)
static

Returns a summary of the output port's current value.

unsigned int getPublishedInputPortCount ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char** getPublishedInputPortDetails ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char** getPublishedInputPortNames ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char** getPublishedInputPortTypes ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char* getPublishedInputPortValue ( char *  portIdentifier,
int  shouldUseInterprocessSerialization 
)

Sends a telemetry error with information about any objects remaining in the reference counting table.

unsigned int getPublishedOutputPortCount ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char** getPublishedOutputPortDetails ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char** getPublishedOutputPortNames ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char** getPublishedOutputPortTypes ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char* getPublishedOutputPortValue ( char *  portIdentifier,
int  shouldUseInterprocessSerialization 
)

Sends a telemetry error with information about any objects remaining in the reference counting table.

void sendError ( const char *  message)

Constructs and sends a message on the telemetry socket, indicating that an uncaught error has occurred.

void sendEventDropped ( char *  portIdentifier)

Constructs and sends a message on the telemetry socket, indicating that a trigger port has dropped an event.

void sendInputPortsUpdated ( char *  portIdentifier,
bool  receivedEvent,
bool  receivedData,
char *  portDataSummary 
)

Constructs and sends a message on the telemetry socket, indicating that an input port has received an event or data.

void sendNodeExecutionFinished ( char *  nodeIdentifier)

Constructs and sends a message on the telemetry socket, indicating that a node has finished execution.

void sendNodeExecutionStarted ( char *  nodeIdentifier)

Constructs and sends a message on the telemetry socket, indicating that a node has started execution.

void sendOutputPortsUpdated ( char *  portIdentifier,
bool  sentData,
char *  portDataSummary 
)

Constructs and sends a message on the telemetry socket, indicating that an output port has transmitted or fired an event.

void sendPublishedOutputPortsUpdated ( char *  portIdentifier,
bool  sentData,
char *  portDataSummary 
)

Constructs and sends a message on the telemetry socket, indicating that a published output port has transmitted an event.

void setPublishedInputPortValue ( char *  portIdentifier,
char *  valueAsString 
)

Sends a telemetry error with information about any objects remaining in the reference counting table.

void stopComposition ( bool  isBeingReplaced,
int  timeoutInSeconds 
)
static

This function is called when the composition receives a stop request (VuoControlRequestCompositionStop), or when the a node or library requests a clean shutdown (VuoStopComposition).

Stop requests are sent both when VuoRunner::stop is called, and during live-coding reloads (so, in the latter case, the composition process will resume after this function is called).

This function may only be called on dispatch queue VuoControlQueue.

void vuoAddCompositionFiniCallback ( VuoCompositionFiniCallback  fini)

Registers a callback to be invoked when the composition is shutting down, after all nodes have been fini'd.

Libraries should call the wrapper VuoAddCompositionFiniCallback.

void vuoCleanup ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

static void vuoControlReplySend ( enum VuoControlReply  reply,
zmq_msg_t *  messages,
unsigned int  messageCount 
)
static

This function may only be called on dispatch queue VuoControlQueue.

void vuoFini ( void  )

Cleans up composition execution: closes the ZMQ sockets and dispatch source and queues.

Assumes the composition has received and replied to a VuoControlRequestCompositionStop message.

void vuoFiniWorkerThreadPool ( void  )

Cleans up the pool of worker threads.

char* vuoGetPortValue ( char *  portIdentifier,
int  serializationType 
)

Sends a telemetry error with information about any objects remaining in the reference counting table.

void VuoHeap_report ( )

Sends a telemetry error with information about any objects remaining in the reference counting table.

void vuoInit ( int  argc,
char **  argv 
)

Parses command-line arguments, then calls vuoInitInProcess().

void vuoInitInProcess ( void *  _ZMQContext,
const char *  controlURL,
const char *  telemetryURL,
bool  _isPaused,
pid_t  _runnerPid,
int  runnerPipe,
bool  continueIfRunnerDies,
bool  trialRestrictionsEnabled,
void *  _VuoCompositionFiniCallbackList 
)

Sets up ZMQ control and telemetry sockets, then calls the generated function vuoSetup().

If the composition is not paused, also calls vuoInstanceInit() and vuoInstanceTriggerStart().

Todo:
When running multiple compositions in the same process, do we need separate pairs? https://b33p.net/kosada/node/10374
void vuoInitWorkerThreadPool ( void  )

Sets up the pool of worker threads.

void vuoInstanceFini ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

void vuoInstanceInit ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

void vuoInstanceTriggerStart ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

void vuoInstanceTriggerStop ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

char* VuoRuntime_mergeEnumDetails ( string  type,
char *  details 
)

If type is an enum, merges the allowed enum values into details and returns it (caller responsible for freeing).

Otherwise, returns NULL.

void VuoRuntime_watchdog ( int  timeoutInSeconds)

If the composition is not stopped within the timeout, kills this process.

char* vuoSerializeTelemetryState ( void  )

Serializes the variables controlling telemetry-sending to a JSON-formatted string.

void vuoSetInputPortValue ( char *  portIdentifier,
char *  valueAsString 
)

Sends a telemetry error with information about any objects remaining in the reference counting table.

void vuoSetup ( void  )

Sends a telemetry error with information about any objects remaining in the reference counting table.

bool vuoShouldSendPortDataTelemetry ( const char *  portIdentifier)

Returns true if telemetry containing the port data summary should be sent for this port.

void vuoStopComposition ( void  )

Nodes/libraries can call this function (via its wrapper, VuoStopComposition) to initiate a clean shutdown of the composition.

It's also called if the VuoRunner dies, the composition is still running, and VuoRunner has requested that the composition be stopped when it dies.

void vuoTelemetrySend ( enum VuoTelemetry  type,
zmq_msg_t *  messages,
unsigned int  messageCount 
)

This function may be called from any thread.

Todo:
https://b33p.net/kosada/node/5567
void vuoUnserializeTelemetryState ( char *  serialized)

Unserializes the variables controlling telemetry-sending from a JSON-formatted string.

Variable Documentation

char* compositionDiff

Differences between the old and new composition, when replacing compositions for live coding.

dispatch_semaphore_t controlCanceledSemaphore
static

Signaled when control events are no longer being processed.

dispatch_source_t controlTimer
static

Timer for receiving control messages.

bool hasBeenUnpaused
static

True if node execution was unpaused initially, or if it has since been unpaused.

bool hasZMQConnection = false

True if the ZMQControl and ZMQTelemetry sockets are connected to something.

bool isPaused

True if node execution is currently paused.

bool isSendingAllTelemetry = false
static

True if all telemetry should be sent.

bool isSendingEventTelemetry = false
static

True if all telemetry about events (not including data) should be sent.

bool isStopped

True if composition execution has stopped.

True if the composition has stopped.

bool isStopRequested

True if vuoStopComposition() has been called.

set<string> portsSendingDataTelemetry
static

Port identifiers for which data-and-event telemetry should be sent.

dispatch_semaphore_t telemetryCanceledSemaphore
static

Signaled when telemetry events are no longer being processed.

dispatch_source_t telemetryTimer
static

Timer for sending telemetry messages.

pid_t VuoApp_runnerPid = 0

Process ID of the runner that started the composition.

VuoCompositionFiniCallbackListType* VuoCompositionFiniCallbackList

Fini callbacks to invoke upon composition shutdown. Non-static, so that VuoCompositionLoader can fetch and restore it during live-coding reloads.

dispatch_queue_t VuoCompositionFiniCallbackQueue = NULL
static

Serializes access to the list of fini callbacks.

dispatch_queue_t VuoCompositionStopQueue = NULL
static

Ensures stops happen serially.

dispatch_queue_t VuoControlQueue
static

Dispatch queue for protecting access to the ZMQControl socket.

dispatch_queue_t VuoTelemetryQueue
static

Dispatch queue for protecting access to the ZMQTelemetry socket.

dispatch_group_t vuoTriggerWorkersScheduled

Keeps track of trigger workers that have been scheduled but have not yet launched an event into the composition.

dispatch_semaphore_t waitForStopCanceledSemaphore
static

Signaled when no longer checking if the runner will stop the composition.

dispatch_source_t waitForStopTimer = NULL
static

Timer for checking if the runner will stop the composition.

bool wasStopCompositionCalled = false
static

Prevents the composition from being finalized twice.

void* ZMQContext
static

The context used to initialize sockets.

void* ZMQControl
static

The control socket. Use only on VuoControlQueue.

void* ZMQSelfReceive = 0
static

Used to break out of a ZMQControl poll.

void* ZMQSelfSend = 0
static

Used to break out of a ZMQControl poll.

void* ZMQTelemetry = 0
static

The telemetry socket. Use only on VuoTelemetryQueue.