basescheduler_decls.h

00001 /*
00002  *  Copyright (C) 2006  Helmut Grohne
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017  */
00018 
00019 #ifndef LIBMUTH_BASESCHEDULER_DECLS_H
00020 #define LIBMUTH_BASESCHEDULER_DECLS_H
00021 
00022 #include <sys/types.h>
00023 #ifndef __WIN32__
00024 #include <sys/time.h>
00025 #include <unistd.h>
00026 #include <sys/socket.h>
00027 #else
00028 #include "win32.h"
00029 #endif
00030 #include "blockingqueue_decls.h"
00031 #include "callback_decls.h"
00032 #include "channel_decls.h"
00033 #include "microthread.h"
00034 
00038 class BaseScheduler : public Microthread {
00039         protected:
00044                 BaseScheduler(BlockingQueue<Microthread*> *q=NULL);
00045         public:
00053                 virtual void addReadCallback(Callback &cb, int fd)=0;
00061                 virtual void addWriteCallback(Callback &cb, int fd)=0;
00069                 virtual void addWaitCallback(Callback &cb,
00070                                 const timeval &tv)=0;
00077                 void addRelativeWaitCallback(Callback &cb,
00078                                 const timeval &tv);
00083                 void scheduleRead(int fd);
00088                 void scheduleWrite(int fd);
00093                 void scheduleWait(const timeval &tv);
00100                 template<class T> void notifyRead(Channel<T> &chan,
00101                                 const T &value, int fd);
00108                 template<class T> void notifyWrite(Channel<T> &chan,
00109                                 const T &value, int fd);
00116                 template<class T> void notifyWait(Channel<T> &chan,
00117                                 const T &value, const timeval &tv);
00118                 virtual void run()=0;
00131                 ssize_t read(int fd, void *buf, size_t count);
00144                 ssize_t write(int fd, const void *buf, size_t count);
00158                 int accept(int sockfd, struct sockaddr *addr,
00159                                 socklen_t *addrlen);
00173                 int connect(int sockfd, const struct sockaddr *serv_addr,
00174                                 socklen_t addrlen);
00184                 unsigned int sleep(unsigned int seconds);
00185 };
00186 
00187 #endif

Generated on Sat Feb 7 01:26:50 2009 by  doxygen 1.5.1