RStudio Launcher Plugin SDK
1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
|
Streams job resource utilization data to the Launcher. More...
#include <AbstractResourceStream.hpp>
Public Member Functions | |
virtual | ~AbstractResourceStream ()=default |
Virtual destructor for inheritance. | |
void | addRequest (uint64_t in_requestId, const system::User &in_requestUser) override |
Adds a request to the stream. More... | |
virtual Error | initialize ()=0 |
Initializes the resource utilization stream. More... | |
void | setStreamComplete () |
Notifies that the data stream has completed. More... | |
Public Member Functions inherited from rstudio::launcher_plugins::api::AbstractMultiStream< ResourceUtilStreamResponse, ResourceUtilData, bool > | |
AbstractMultiStream (comms::AbstractLauncherCommunicatorPtr in_launcherCommunicator) | |
Constructor. More... | |
bool | isEmpty () const |
Checks whether there are any requests listening to this stream. More... | |
virtual void | removeRequest (uint64_t in_requestId) |
Removes a request from the multi-stream response. More... | |
Public Member Functions inherited from rstudio::launcher_plugins::Noncopyable | |
Noncopyable ()=default | |
Default constructor. | |
Noncopyable (const Noncopyable &)=delete | |
Deleted copy constructor. | |
Noncopyable & | operator= (const Noncopyable &)=delete |
Deleted assignment operator. | |
Protected Member Functions | |
AbstractResourceStream (const ConstJobPtr &in_job, comms::AbstractLauncherCommunicatorPtr in_launcherCommunicator) | |
Constructor. More... | |
void | reportData (const ResourceUtilData &in_data) |
Reports resource utilization data to the Launcher. More... | |
void | reportError (const Error &in_error) |
Reports an error to the Launcher. More... | |
Protected Member Functions inherited from rstudio::launcher_plugins::api::AbstractMultiStream< ResourceUtilStreamResponse, ResourceUtilData, bool > | |
void | onAddRequest (uint64_t in_requestId) |
Adds a new request ID to the multi-stream response. More... | |
void | onRemoveRequest (uint64_t in_requestId) |
Removes a request from the multi-stream response. More... | |
void | sendResponse (Args... in_responseArgs) |
Sends a response to the Launcher for all requests. More... | |
void | sendResponse (const std::set< uint64_t > &in_requestIds, Args... in_responseArgs) |
Sends a response to the Launcher for the specified requests. More... | |
Protected Attributes | |
const ConstJobPtr | m_job |
The job for which resource utilization metrics should be streamed. More... | |
Protected Attributes inherited from rstudio::launcher_plugins::api::AbstractMultiStream< ResourceUtilStreamResponse, ResourceUtilData, bool > | |
std::mutex | m_mutex |
Streams job resource utilization data to the Launcher.
|
protected |
Constructor.
in_job | The job for which resource utilization metrics should be streamed. |
in_launcherCommunicator | The communicator through which messages may be sent to the launcher. |
|
overridevirtual |
Adds a request to the stream.
in_requestId | The ID of the request. |
in_requestUser | The user who made the request. |
Implements rstudio::launcher_plugins::api::AbstractMultiStream< ResourceUtilStreamResponse, ResourceUtilData, bool >.
|
pure virtual |
Initializes the resource utilization stream.
Implements rstudio::launcher_plugins::api::AbstractMultiStream< ResourceUtilStreamResponse, ResourceUtilData, bool >.
Implemented in rstudio::launcher_plugins::api::AbstractTimedResourceStream, and rstudio::launcher_plugins::quickstart::QuickStartResourceStream.
|
protected |
Reports resource utilization data to the Launcher.
in_data | The new resource utilization data for this job. |
|
protected |
Reports an error to the Launcher.
Additional calls to reportError, reportData, or setStreamComplete will be ignored.
in_error | The error which occurred. |
void rstudio::launcher_plugins::api::AbstractResourceStream::setStreamComplete | ( | ) |
Notifies that the data stream has completed.
Additional calls to reportError, reportData, or setStreamComplete will be ignored.
|
protected |
The job for which resource utilization metrics should be streamed.
NOTE: To avoid potential deadlock scenarios, the lock for the mutex on the base class, m_mutex, must be held when the job lock is acquired, and the job lock must be released before the mutex lock is released. For consistency, it is recommended to use the following block of code to acquire both locks:
LOCK_MUTEX_AND_JOB(std::lock_guard, std::mutex, m_mutex, m_job) { // Do tasks which require the Job Lock. } END_LOCK_MUTEX_AND_JOB