4 #include "condition.inc"
11 // Load balancing utils
12 // There is no guarantee that all the load clients will be run in a
13 // processing operation.
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
35 LoadClient(LoadServer
*server
);
37 virtual ~LoadClient();
39 // Called when run as distributed client
41 // Called when run as a single_client
43 virtual void process_package(LoadPackage
*package
);
44 int get_package_number();
45 LoadServer
* get_server();
49 Condition
*input_lock
;
50 Condition
*completion_lock
;
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();
98 LoadPackage
**packages
;
100 LoadClient
**clients
;
101 LoadClient
*single_client
;