Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/downloader/asyncUtility.h

Go to the documentation of this file.
00001 // Filename: asyncUtility.h
00002 // Created by:  mike (09Jan97)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 #ifndef ASYNCUTILITY_H
00019 #define ASYNCUTILITY_H
00020 //
00021 ////////////////////////////////////////////////////////////////////
00022 // Includes
00023 ////////////////////////////////////////////////////////////////////
00024 #include <pandabase.h>
00025 #include <notify.h>
00026 #include <typedef.h>
00027 
00028 #ifdef OLD_HAVE_IPC
00029 #include <ipc_mutex.h>
00030 #include <ipc_condition.h>
00031 #include <ipc_thread.h>
00032 #endif
00033 
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : AsyncUtility
00037 // Description :
00038 ////////////////////////////////////////////////////////////////////
00039 class EXPCL_PANDAEXPRESS AsyncUtility {
00040 PUBLISHED:
00041   INLINE void set_frequency(float frequency);
00042   INLINE float get_frequency(void) const;
00043 
00044   void create_thread(void);
00045 
00046 public:
00047   AsyncUtility(float frequency = 0.2);
00048   virtual ~AsyncUtility(void);
00049 
00050 protected:
00051   void destroy_thread(void);
00052   static void* st_callback(void *arg);
00053   void callback(void);
00054   virtual bool process_request(void) = 0;
00055   void nap(void) const;
00056 
00057 protected:
00058   int _next_token;
00059   bool _shutdown;
00060   bool _threaded;
00061   float _frequency;
00062   bool _threads_enabled;
00063 
00064 #ifdef OLD_HAVE_IPC
00065   mutex _lock;
00066   condition_variable *_request_cond;
00067   thread *_thread;
00068 #endif
00069 };
00070 
00071 #include "asyncUtility.I"
00072 
00073 #endif

Generated on Fri May 2 00:36:42 2003 for Panda by doxygen1.3