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
32 class LoadClient
: public Thread
35 LoadClient(LoadServer
*server
);
36 virtual ~LoadClient();
39 virtual void process_package(LoadPackage
*package
) {};
40 int get_package_number();
41 LoadServer
* get_server();
45 Condition
*input_lock
;
46 Condition
*completion_lock
;
56 LoadServer(int total_clients
, int total_packages
);
57 virtual ~LoadServer();
59 friend class LoadClient
;
61 // Called first in process_packages. Should also initialize clients.
62 virtual void init_packages() {};
63 virtual LoadClient
* new_client() { return 0; };
64 virtual LoadPackage
* new_package() { return 0; };
66 // User calls this to do an iteration
67 void process_packages();
70 int get_total_packages();
71 int get_total_clients();
72 LoadPackage
* get_package(int number
);
73 LoadClient
* get_client(int number
);
74 void set_package_count(int total_packages
);
78 void delete_clients();
79 void create_clients();
80 void delete_packages();
81 void create_packages();
88 LoadPackage
**packages
;