RStudio Launcher Plugin SDK
1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
|
24 #ifndef LAUNCHER_PLUGINS_ASIO_HPP
25 #define LAUNCHER_PLUGINS_ASIO_HPP
27 #include <Noncopyable.hpp>
35 namespace launcher_plugins {
45 typedef std::function<void()> AsioFunction;
50 typedef std::function<void(
const char*,
size_t)> OnReadBytes;
55 typedef std::function<void(
int)> OnSignal;
69 static void post(
const AsioFunction& in_work);
99 static void waitForExit();
115 PRIVATE_IMPL_SHARED(m_impl);
139 void close() noexcept;
147 void readBytes(
const OnReadBytes& in_onReadBytes,
const OnError& in_onError);
156 const std::string& in_data,
158 const AsioFunction& in_onFinishedWriting = AsioFunction());
162 PRIVATE_IMPL_SHARED(m_impl);
205 PRIVATE_IMPL_SHARED(m_impl);
246 PRIVATE_IMPL_SHARED(m_impl);
void close() noexcept
Closes the stream. Nothing may be read from or written to the stream after this is called.
Async input/output class which may be used to manage ASIO operations.
Definition: Asio.hpp:60
~AsyncDeadlineEvent()
Destructor. The event will be canceled if this invoked before the deadline time.
Class which may be used to post async work to be performed at a later time.
Definition: Asio.hpp:211
static void setSignalHandler(const OnSignal &in_onSignal)
Sets the signal handler on the ASIO service.
void start()
Starts waiting for the event.
AsioStream(int in_streamHandle)
Constructor.
Class which performs an action asynchronously every specified number of seconds.
Definition: Asio.hpp:168
void cancel()
Cancels the event, if invoked before the deadline time.
Class which allows reading from or writing to streams asynchronously.
Definition: Asio.hpp:121
void start(const TimeDuration &in_timeDuration, const AsioFunction &in_event)
Starts performing the specified event every in_timeDuration.
static void post(const AsioFunction &in_work)
Posts a job to be completed by this ASIO Service.
std::function< void(const Error &)> OnError
Definition: Functionals.hpp:43
void reportError(const Error &in_error)
Reports a fatal error to the AsyncTimedEvent instance. Invoking this will cause the timed event to st...
static void startThreads(size_t in_numThreads)
Creates and adds the specified number of worker threads to the ASIO service.
Class which represents a date and time in UTC.
Definition: DateTime.hpp:244
AsyncTimedEvent()
Default constructor.
Class which represents an error.
Definition: Error.hpp:174
Represents an duration of time (e.g. 5 hours, 43 minutes, and 21 seconds) as opposed to a point in ti...
Definition: DateTime.hpp:48
~AsioStream() noexcept
Destructor. Closes the stream.
static void stop()
Stops the ASIO Service.
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
void writeBytes(const std::string &in_data, const OnError &in_onError, const AsioFunction &in_onFinishedWriting=AsioFunction())
Writes the provided data to the stream asynchronously.
void cancel()
Cancels the timed event.
AsyncDeadlineEvent(const AsioFunction &in_work, const DateTime &in_deadlineTime)
Constructor.
void readBytes(const OnReadBytes &in_onReadBytes, const OnError &in_onError)
Attempts to read bytes from this ASIO stream.