Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

if/core/bsched.h

Go to the documentation of this file.
00001 /*
00002  * $Id: bsched.h 12583 2006-12-06 05:42:15Z cbiere $
00003  *
00004  * Copyright (c) 2001-2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00026 #ifndef _if_core_bsched_h_
00027 #define _if_core_bsched_h_
00028 
00029 #include "if/core/wrap.h"   /* For wrap_io_t */
00030 #include "lib/inputevt.h"   /* For inputevt_handler_t */
00031 
00032 #define BS_BW_MAX   (2*1024*1024)
00033 
00034 typedef struct bsched bsched_t;
00035 
00036 typedef enum {
00037     BSCHED_BWS_IN,
00038     BSCHED_BWS_OUT,
00039     BSCHED_BWS_GIN,
00040     BSCHED_BWS_GOUT,
00041     BSCHED_BWS_GLIN,
00042     BSCHED_BWS_GLOUT,
00043     BSCHED_BWS_GIN_UDP,
00044     BSCHED_BWS_GOUT_UDP,
00045 
00046     NUM_BSCHED_BWS,
00047     BSCHED_BWS_INVALID = NUM_BSCHED_BWS
00048 } bsched_bws_t;
00049 
00054 enum bio_source_magic { BIO_SOURCE_MAGIC = 0x80b3bf07U };
00055 
00056 typedef struct bio_source {
00057     enum bio_source_magic magic;    
00058     bsched_bws_t bws;                   
00059     wrap_io_t *wio;                 
00060     gint io_tag;                    
00061     guint io_flags;                 
00062     inputevt_handler_t io_callback;     
00063     gpointer io_arg;                
00064     guint32 flags;                  
00065     guint bw_actual;                
00066     guint bw_last_bps;              
00067     guint bw_fast_ema;              
00068     guint bw_slow_ema;              
00069 } bio_source_t;
00070 
00071 /*
00072  * Source flags.
00073  */
00074 
00075 #define BIO_F_READ          0x00000001  
00076 #define BIO_F_WRITE         0x00000002  
00077 #define BIO_F_ACTIVE        0x00000004  
00078 #define BIO_F_USED          0x00000008  
00080 #define BIO_F_RW            (BIO_F_READ|BIO_F_WRITE)
00081 
00082 #define BIO_EMA_SHIFT   7
00083 
00084 #define bio_bps(b)      ((b)->bw_last_bps)
00085 #define bio_avg_bps(b)  ((b)->bw_slow_ema >> BIO_EMA_SHIFT)
00086 
00087 #endif /* _if_core_bsched_h_ */
00088 
00089 /* vi: set ts=4: */

Generated on Sat Jun 30 17:53:22 2007 for gtk-gnutella by  doxygen 1.3.9.1