*/
#include <stddef.h>
#include <dpl/socket/waitable_input_output_execution_context_support.h>
-#include <dpl/scoped_array.h>
#include <dpl/socket/abstract_socket.h> // FIXME: Remove !!!
-#include <dpl/log/log.h>
+#include <dpl/log/wrt_log.h>
#include <dpl/assert.h>
namespace DPL {
Throw(Exception::AlreadyOpened);
}
- LogPedantic("Opening waitable input-output execution context support...");
+ WrtLogD("Opening waitable input-output execution context support...");
// Save IO handle
m_waitableInputOutput = inputOutput;
// Done
m_opened = true;
- LogPedantic("Waitable input-output execution context support opened");
+ WrtLogD("Waitable input-output execution context support opened");
}
void WaitableInputOutputExecutionContextSupport::Close()
return;
}
- LogPedantic("Closing waitable input-output execution context support...");
+ WrtLogD("Closing waitable input-output execution context support...");
// Remove read and write watches
CheckedRemoveReadWriteWatch();
// Set proper state
m_opened = false;
- LogPedantic("Waitable input-output execution context support closed");
+ WrtLogD("Waitable input-output execution context support closed");
}
void WaitableInputOutputExecutionContextSupport::AddReadWatch()
{
- WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
- this,
- m_waitableInputOutput
- ->WaitableReadHandle(),
- WaitMode
- ::Read);
+ WaitableHandleWatchSupport* ctx =
+ WaitableHandleWatchSupport::InheritedContext();
+ if(ctx)
+ ctx->AddWaitableHandleWatch(
+ this,
+ m_waitableInputOutput->WaitableReadHandle(),
+ WaitMode::Read);
}
void WaitableInputOutputExecutionContextSupport::RemoveReadWatch()
{
- WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(
- this,
- m_waitableInputOutput->WaitableReadHandle(),
- WaitMode::Read);
+ WaitableHandleWatchSupport* ctx =
+ WaitableHandleWatchSupport::InheritedContext();
+ if(ctx)
+ ctx->RemoveWaitableHandleWatch(
+ this,
+ m_waitableInputOutput->WaitableReadHandle(),
+ WaitMode::Read);
}
void WaitableInputOutputExecutionContextSupport::AddWriteWatch()
{
- WaitableHandleWatchSupport::InheritedContext()->AddWaitableHandleWatch(
- this,
- m_waitableInputOutput
- ->WaitableWriteHandle(),
- WaitMode
- ::Write);
+ WaitableHandleWatchSupport* ctx =
+ WaitableHandleWatchSupport::InheritedContext();
+ if(ctx)
+ ctx->AddWaitableHandleWatch(
+ this,
+ m_waitableInputOutput->WaitableWriteHandle(),
+ WaitMode::Write);
}
void WaitableInputOutputExecutionContextSupport::RemoveWriteWatch()
{
- WaitableHandleWatchSupport::InheritedContext()->RemoveWaitableHandleWatch(
- this,
- m_waitableInputOutput->WaitableWriteHandle(),
- WaitMode::Write);
+ WaitableHandleWatchSupport* ctx =
+ WaitableHandleWatchSupport::InheritedContext();
+ if(ctx)
+ ctx->RemoveWaitableHandleWatch(
+ this,
+ m_waitableInputOutput->WaitableWriteHandle(),
+ WaitMode::Write);
}
void WaitableInputOutputExecutionContextSupport::CheckedRemoveReadWatch()
switch (mode) {
case WaitMode::Read:
- LogPedantic("Read event occurred");
+ WrtLogD("Read event occurred");
// Read and parse bytes
ReadInput();
break;
case WaitMode::Write:
- LogPedantic("Write event occurred");
+ WrtLogD("Write event occurred");
// Push bytes and unregister from write event
FeedOutput();
void WaitableInputOutputExecutionContextSupport::ReadInput()
{
- LogPedantic("Reading input bytes");
+ WrtLogD("Reading input bytes");
Try
{
if (inputBuffer.get() == NULL) {
// No data, should not occur
- LogPedantic("WARNING: Spontaneous ReadSocket occurred");
+ WrtLogD("WARNING: Spontaneous ReadSocket occurred");
return;
}
return;
}
- LogPedantic("Read " << inputBuffer->Size() << " input bytes");
+ WrtLogD("Read %i input bytes", inputBuffer->Size());
// Append all read data
m_inputStream.AppendMoveFrom(*inputBuffer);
//FIXME: Inproper exception abstraction!!!
// Some errors occurred while feeding abstract IO
// Interpret connection broken errors, and pass futher other ones
- LogPedantic("Abstract IO connection was broken during read");
+ WrtLogD("Abstract IO connection was broken during read");
// Signal broken connection
OnInputStreamBroken();
}
// OK to feed output
- LogPedantic("Feeding output");
+ WrtLogD("Feeding output");
Try
{
AddWriteWatch();
m_hasWriteWatch = true;
- LogPedantic("Started exhaustive output feeding");
+ WrtLogD("Started exhaustive output feeding");
}
}
{
// Some errors occurred while feeding abstract IO
// Interpret connection broken errors, and pass futher other ones
- LogPedantic("Abstract IO connection was broken during write");
+ WrtLogD("Abstract IO connection was broken during write");
// Signal broken connection
OnInputStreamBroken();