r807: Minor fix...
[cinelerra_cv/mob.git] / cinelerra / loadbalance.h
blob332c277f5d5df05c218e5ac695ce0e3a8161008c
1 #ifndef LOADBALANCE_H
2 #define LOADBALANCE_H
4 #include "condition.inc"
5 #include "mutex.inc"
6 #include "thread.h"
11 // Load balancing utils
12 // There is no guarantee that all the load clients will be run in a
13 // processing operation.
16 class LoadServer;
20 class LoadPackage
22 public:
23 LoadPackage();
24 virtual ~LoadPackage();
26 Condition *completion_lock;
27 // Range to search in the total scan area
28 // int pixel1, pixel2;
32 class LoadClient : public Thread
34 public:
35 LoadClient(LoadServer *server);
36 LoadClient();
37 virtual ~LoadClient();
39 void run();
40 virtual void process_package(LoadPackage *package) {};
41 int get_package_number();
42 LoadServer* get_server();
44 int done;
45 int package_number;
46 Condition *input_lock;
47 Condition *completion_lock;
48 LoadServer *server;
54 class LoadServer
56 public:
57 LoadServer(int total_clients, int total_packages);
58 virtual ~LoadServer();
60 friend class LoadClient;
62 // Called first in process_packages. Should also initialize clients.
63 virtual void init_packages() {};
64 virtual LoadClient* new_client() { return 0; };
65 virtual LoadPackage* new_package() { return 0; };
67 // User calls this to do an iteration
68 void process_packages();
71 int get_total_packages();
72 int get_total_clients();
73 LoadPackage* get_package(int number);
74 LoadClient* get_client(int number);
75 void set_package_count(int total_packages);
79 void delete_clients();
80 void create_clients();
81 void delete_packages();
82 void create_packages();
88 int current_package;
89 LoadPackage **packages;
90 int total_packages;
91 LoadClient **clients;
92 int total_clients;
93 Mutex *client_lock;
98 #endif