Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for large asynchronous writes. (too big for a single writev call) #3

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
18 changes: 12 additions & 6 deletions README.md
Expand Up @@ -5,6 +5,11 @@ Multipurpose concurrent I/O framework for C++

## Overview

This is a fork of the Multi-Purpose IO library written frsyuki.
I noticed some issues scheduling tasks with his original code that I've tried to fix and thought I'd have a go at documenting the code a bit.
The wavy\_loop thread\_main is significantly simpler in this version.
Note: I haven't tested this on anything besides linux.


## Installation

Expand All @@ -16,6 +21,7 @@ Following libraries are required to build mpio:
- FreeBSD >= ?
- NetBSD >= ?
- g++ >= 4.1
- [google logging](http://google-glog.googlecode.com/svn/trunk/doc/glog.html)

Configure and install in the usual way:

Expand All @@ -27,13 +33,13 @@ Configure and install in the usual way:

## Libraries

[Test cases](http://github.com/frsyuki/mpio/tree/master/test/) will give you a sample usage.
[Test cases](http://github.com/aarond10/mpio/tree/master/test/) will give you a sample usage.

- [event handler](http://github.com/frsyuki/mpio/blob/master/test/handler.cc)
- [listen and connect](http://github.com/frsyuki/mpio/blob/master/test/listen_connect.cc)
- [timer](http://github.com/frsyuki/mpio/blob/master/test/timer.cc)
- [signal handling](http://github.com/frsyuki/mpio/blob/master/test/signal.cc)
- [mp::sync](http://github.com/frsyuki/mpio/blob/master/test/sync.cc)
- [event handler](http://github.com/aarond10/mpio/blob/master/test/handler.cc)
- [listen and connect](http://github.com/aarond10/mpio/blob/master/test/listen_connect.cc)
- [timer](http://github.com/aarond10/mpio/blob/master/test/timer.cc)
- [signal handling](http://github.com/aarond10/mpio/blob/master/test/signal.cc)
- [mp::sync](http://github.com/aarond10/mpio/blob/master/test/sync.cc)


### Wavy
Expand Down
2 changes: 1 addition & 1 deletion mp/pthread.h
Expand Up @@ -149,7 +149,7 @@ class pthread_mutex {
private:
pthread_mutex_t m_mutex;
private:
pthread_mutex(const pthread_mutex&);
pthread_mutex(const pthread_mutex&); // No copy constructor.
};


Expand Down
9 changes: 8 additions & 1 deletion mp/wavy.hmpl
Expand Up @@ -46,7 +46,11 @@ class xfer;
typedef shared_ptr<basic_handler> shared_handler;
typedef weak_ptr<basic_handler> weak_handler;


/**
* Multi-Purpose IO event loop(s).
* This class runs one or more threads that asynchronously process events.
* It can handle file descriptors, sockets, signals, and timers.
*/
class loop {
public:
typedef mp::wavy::basic_handler basic_handler;
Expand All @@ -58,6 +62,9 @@ public:

~loop();

/**
* Start a number of worker threads.
*/
void start(size_t num);

void run(size_t num); // run = start + join
Expand Down
10 changes: 10 additions & 0 deletions mpsrc/wavy_kernel_epoll.h
Expand Up @@ -50,6 +50,16 @@ static const short EVKERNEL_READ = EPOLLIN;
static const short EVKERNEL_WRITE = EPOLLOUT;


/**
* epoll_* based multiplexing kernel
*
* Provides a means for both blocking and non-blocking listening on
* file descriptora, timers, signals and another kernels.
*
* Note that kernel's can be added to each other in a tree. In such a
* situation, the FD event triggered by the root of the tree will be for
* the kernel the level down, *not* the leaf.
*/
class kernel {
public:
kernel() : m_ep(epoll_create(MP_WAVY_KERNEL_BACKLOG_SIZE))
Expand Down