Show
Ignore:
Timestamp:
08/27/08 15:40:53 (4 months ago)
Author:
frsyuki
Message:

lang/c/mpio: re-implemented mp::fdnotify with readv() system call

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/c/mpio/trunk/mp/fdnotify.h

    r18183 r18301  
    1717// 
    1818 
    19 #ifndef MP_FD_NOTIFY_H__ 
    20 #define MP_FD_NOTIFY_H__ 
     19#ifndef MP_FDNOTIFY_H__ 
     20#define MP_FDNOTIFY_H__ 
    2121 
     22#include <sys/types.h> 
     23#include <sys/uio.h> 
     24#include <unistd.h> 
    2225#include <stdexcept> 
     26 
     27#ifndef MP_FDNOTIFY_VECTOR_SIZE 
     28#define MP_FDNOTIFY_VECTOR_SIZE 64 
     29#endif 
    2330 
    2431namespace mp { 
     
    4047 
    4148public: 
     49        int getfd(void) const { return m_pipe[0]; } 
    4250        bool try_receive(NotifyObject* result); 
    43         int getfd(void) const { return m_pipe[PIPE_READ]; } 
    4451 
    45         inline void send(const NotifyObject& obj); 
     52        void send(const NotifyObject& obj); 
    4653 
    4754private: 
    48         enum { 
    49                 PIPE_READ = 0, 
    50                 PIPE_WRITE = 1, 
    51         }; 
    5255        int m_pipe[2]; 
    53         char m_buffer[sizeof(NotifyObject)]; 
    54         size_t m_pos; 
     56        char m_buffer[sizeof(NotifyObject)*MP_FDNOTIFY_VECTOR_SIZE]; 
     57        struct iovec m_iovec[MP_FDNOTIFY_VECTOR_SIZE]; 
     58        struct iovec* m_head; 
     59        struct iovec* m_tail; 
    5560 
    5661private: 
    57         void send_all(const char* p, const char* const endp); 
     62        bool receive_next(NotifyObject* result); 
    5863 
    5964private: