NVIDIA Iray API Home  Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::bridge::IServer_job Class Referenceabstract

Represents the server-side part of a job that can be executed by the Bridge server. More...

Inheritance diagram for mi::bridge::IServer_job:
Inheritance graph
[legend]

Public Member Functions

virtual void  execute (IServer_transaction *transaction, neuraylib::ISerializer *serializer)=0
  Executes a job on behalf of a Bridge client. More...
 
virtual void  cancel ()=0
  Called if the Bridge transaction is aborted or if an error occurs. More...
 

Additional Inherited Members

- Public Types inherited from mi::base::Interface_declare< 0x555dea0f, 0x4eeb, 0x44b9, 0xba, 0x81, 0x5a, 0x42, 0x3d, 0xe5, 0xf8, 0x30, neuraylib::ISerializable >
typedef Interface_declare< id1,
id2, id3, id4, id5, id6, id7,
id8, id9, id10, id11,
neuraylib::ISerializable
Self
  Own type. More...
 
typedef Uuid_t< id1, id2, id3,
id4, id5, id6, id7, id8, id9,
id10, id11 > 
IID
  Declares the interface ID (IID) of this interface. More...
 
- Static Public Member Functions inherited from mi::base::Interface_declare< 0x555dea0f, 0x4eeb, 0x44b9, 0xba, 0x81, 0x5a, 0x42, 0x3d, 0xe5, 0xf8, 0x30, neuraylib::ISerializable >
static bool  compare_iid (const Uuid &iid)
  Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
 

Detailed Description

Represents the server-side part of a job that can be executed by the Bridge server.

The corresponding client-side part of the job must return the same ID from mi::neuraylib::ISerializable::get_class_id() and be registered as a Bridge job on the client.

The server-side part must implement mi::neuraylib::ISerializable::deserialize() to deserialize the data that is sent by mi::bridge::IClient_job::serialize(), and mi::bridge::IServer_job::execute() to serialize the result of the job which is consumed by mi::bridge::IClient_job::receive_remote_result(),

It is recommended to derived your implementation from mi::bridge::Server_job and overriding only the required methods.

Member Function Documentation

virtual void mi::bridge::IServer_job::cancel ( )
pure virtual

Called if the Bridge transaction is aborted or if an error occurs.

The job execution should be stopped as quickly as possible, no result will be written to the client.

virtual void mi::bridge::IServer_job::execute ( IServer_transaction transaction,
neuraylib::ISerializer serializer 
)
pure virtual

Executes a job on behalf of a Bridge client.

Intermediate results can be sent to the client by calling mi::neuraylib::ISerializer::flush() on serializer. All data serialized until that point will be delivered in a single call to mi::bridge::IClient_job::receive_remote_result() on the client with the last_result flag set to false. When execute() returns any data not yet flushed will be flushed and mi::bridge::IClient_job::receive_remote_result() will be called one last time with last_result flag set to true.

Example 1: No intermediate results are required. The execute() method simply serializes the result and returns. The receive_remote_result() method will be called once with the full result and last_result flag set to true.

Example 2: Progress feedback. During execution of the job periodically one mi::Float32 representing the percentage of the work done is serialized periodically and the serializer is flushed. Finally, when the job is done the final result is serialized and the method returns. On the client side receive_remote_result() parses a single mi::Float32 for every call with the last_result flag set to false and updates a progress bar. When last_result is true it deserializes the entire result and is done.

Example 3: Custom protocol. Whenever the server is done with a partial result it is flushed as a chunk to the client for processing. The server is preparing multiple different types of results, so the chunk always begins with a mi::Uint8 which identifies the type of the chunk and the data to expect. After flushing the last chunk the execute() method returns without any pending data. On the client side receive_remote_result() will check the last_result flag. If true, then the job is done, no more data to parse. If false the first mi::Uint8 is deserialized and the rest of the data is deserialized depending on the type of the chunk and then processed.

Parameters
transaction The Bridge transaction to be used for the job execution.
serializer The serializer to be used to send the result back to the client.