r1009: Move the dependencies to newer package names
[cinelerra_cv/mob.git] / cinelerra / loadbalance.h
bloba7981f82b03ae878130276edb7d4b8f0e7e743b4
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 // Called when run as distributed client
40 void run();
41 // Called when run as a single_client
42 void run_single();
43 virtual void process_package(LoadPackage *package);
44 int get_package_number();
45 LoadServer* get_server();
47 int done;
48 int package_number;
49 Condition *input_lock;
50 Condition *completion_lock;
51 LoadServer *server;
57 class LoadServer
59 public:
60 LoadServer(int total_clients, int total_packages);
61 virtual ~LoadServer();
63 friend class LoadClient;
65 // Called first in process_packages. Should also initialize clients.
66 virtual void init_packages() {};
67 virtual LoadClient* new_client() { return 0; };
68 virtual LoadPackage* new_package() { return 0; };
70 // User calls this to do an iteration with the distributed clients
71 void process_packages();
73 // Use this to do an iteration with one client, in the current thread.
74 // The single client is created specifically for this call and deleted in
75 // delete_clients. This simplifies the porting to OpenGL.
76 // total_packages must be > 0.
77 void process_single();
79 // These values are computed from the value of is_single.
80 int get_total_packages();
81 int get_total_clients();
82 LoadPackage* get_package(int number);
83 LoadClient* get_client(int number);
84 void set_package_count(int total_packages);
88 void delete_clients();
89 void create_clients();
90 void delete_packages();
91 void create_packages();
96 private:
97 int current_package;
98 LoadPackage **packages;
99 int total_packages;
100 LoadClient **clients;
101 LoadClient *single_client;
102 int total_clients;
103 int is_single;
104 Mutex *client_lock;
109 #endif