summaryrefslogtreecommitdiffstats
path: root/client/windows/named_pipe.h
diff options
context:
space:
mode:
authorYonit Halperin <yhalperi@redhat.com>2009-11-08 16:34:12 +0200
committerYaniv Kamay <ykamay@redhat.com>2009-11-09 14:39:33 +0200
commit8d5b738ba169c44d223ab6d99ec12e763ce5bc8e (patch)
tree3c1d4dd1b3c32f9a03dd456ea921a66ed7f6c7fd /client/windows/named_pipe.h
parent082934699611d5985ecf3386259d270d75e41c12 (diff)
downloadspice-8d5b738ba169c44d223ab6d99ec12e763ce5bc8e.tar.gz
spice-8d5b738ba169c44d223ab6d99ec12e763ce5bc8e.tar.xz
spice-8d5b738ba169c44d223ab6d99ec12e763ce5bc8e.zip
spice client: creating a general process loop.
The process loop is responsible for: 1) waiting for events 2) timers 3) events queue for actions that should be performed in the context of the thread and are pushed from other threads. The benefits: 1) remove duplicity: till now, there was one implementaion of events loop for the channels and another one for the main thread. 2) timers can be executed on each thread and not only on the main thread. 3) events can be pushed to each thread and not only to the main thread. In this commit, only the main thread was modified to use the new process loop.
Diffstat (limited to 'client/windows/named_pipe.h')
-rw-r--r--client/windows/named_pipe.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/client/windows/named_pipe.h b/client/windows/named_pipe.h
index 578c34d2..fcdc0dd7 100644
--- a/client/windows/named_pipe.h
+++ b/client/windows/named_pipe.h
@@ -19,8 +19,9 @@
#define _H_NAMED_PIPE
#include <windows.h>
+#include "process_loop.h"
+#include "event_sources.h"
#include "platform.h"
-#include "win_platform.h"
#define PIPE_TIMEOUT 5000
#define PIPE_BUF_SIZE 8192
@@ -29,9 +30,9 @@
class WinConnection;
-class PipeBuffer: public EventOwner {
+class PipeBuffer: public EventSources::Handle {
public:
- PipeBuffer(HANDLE pipe);
+ PipeBuffer(HANDLE pipe, ProcessLoop& process_loop);
~PipeBuffer();
void set_handler(NamedPipe::ConnectionInterface* handler) { _handler = handler;}
DWORD get_overlapped_bytes();
@@ -44,25 +45,26 @@ protected:
uint32_t _end;
uint8_t _data[PIPE_BUF_SIZE];
bool _pending;
+ ProcessLoop& _process_loop;
};
class PipeReader: public PipeBuffer {
public:
- PipeReader(HANDLE pipe) : PipeBuffer(pipe) {}
+ PipeReader(HANDLE pipe, ProcessLoop& process_loop) : PipeBuffer(pipe, process_loop) {}
int32_t read(uint8_t *buf, int32_t size);
void on_event();
};
class PipeWriter: public PipeBuffer {
public:
- PipeWriter(HANDLE pipe) : PipeBuffer(pipe) {}
+ PipeWriter(HANDLE pipe, ProcessLoop& process_loop) : PipeBuffer(pipe, process_loop) {}
int32_t write(const uint8_t *buf, int32_t size);
void on_event();
};
class WinConnection {
public:
- WinConnection(HANDLE pipe);
+ WinConnection(HANDLE pipe, ProcessLoop& process_loop);
~WinConnection();
int32_t read(uint8_t *buf, int32_t size);
int32_t write(const uint8_t *buf, int32_t size);
@@ -74,9 +76,10 @@ private:
PipeReader _reader;
};
-class WinListener: public EventOwner {
+class WinListener: public EventSources::Handle {
public:
- WinListener(const char *name, NamedPipe::ListenerInterface &listener_interface);
+ WinListener(const char *name, NamedPipe::ListenerInterface &listener_interface,
+ ProcessLoop& process_loop);
~WinListener();
void on_event();
@@ -88,6 +91,7 @@ private:
NamedPipe::ListenerInterface &_listener_interface;
OVERLAPPED _overlap;
HANDLE _pipe;
+ ProcessLoop& _process_loop;
};
#endif