Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

loadbalance.h

Go to the documentation of this file.
00001 #ifndef LOADBALANCE_H
00002 #define LOADBALANCE_H
00003 
00004 #include "condition.inc"
00005 #include "mutex.inc"
00006 #include "thread.h"
00007 
00008 
00009 
00010 
00011 // Load balancing utils
00012 // There is no guarantee that all the load clients will be run in a 
00013 // processing operation.
00014 
00015 
00016 class LoadServer;
00017 
00018 
00019 
00020 class LoadPackage
00021 {
00022 public:
00023         LoadPackage();
00024         virtual ~LoadPackage();
00025         
00026         Condition *completion_lock;
00027 // Range to search in the total scan area
00028 //      int pixel1, pixel2;
00029 };
00030 
00031 
00032 class LoadClient : public Thread
00033 {
00034 public:
00035         LoadClient(LoadServer *server);
00036         LoadClient();
00037         virtual ~LoadClient();
00038         
00039         void run();
00040         virtual void process_package(LoadPackage *package) {};
00041         int get_package_number();
00042         LoadServer* get_server();
00043 
00044         int done;
00045         int package_number;
00046         Condition *input_lock;
00047         Condition *completion_lock;
00048         LoadServer *server;
00049 };
00050 
00051 
00052 
00053 
00054 class LoadServer
00055 {
00056 public:
00057         LoadServer(int total_clients, int total_packages);
00058         virtual ~LoadServer();
00059 
00060         friend class LoadClient;
00061 
00062 // Called first in process_packages.  Should also initialize clients.
00063         virtual void init_packages() {};
00064         virtual LoadClient* new_client() { return 0; };
00065         virtual LoadPackage* new_package() { return 0; };
00066 
00067 // User calls this to do an iteration
00068         void process_packages();
00069 
00070 
00071         int get_total_packages();
00072         int get_total_clients();
00073         LoadPackage* get_package(int number);
00074         LoadClient* get_client(int number);
00075         void set_package_count(int total_packages);
00076 
00077 
00078 
00079         void delete_clients();
00080         void create_clients();
00081         void delete_packages();
00082         void create_packages();
00083 
00084 
00085 
00086 
00087 
00088         int current_package;
00089         LoadPackage **packages;
00090         int total_packages;
00091         LoadClient **clients;
00092         int total_clients;
00093         Mutex *client_lock;
00094 };
00095 
00096 
00097 
00098 #endif
00099 
00100 

Generated on Sun Jan 8 13:38:56 2006 for Cinelerra-svn by  doxygen 1.4.4