# # # patch "automate.cc" # from [f9b4f9ac8a7b375484336b4e13d80c39c3720e43] # to [8017e36c8cc1681d756239707e409b0d81881039] # # patch "file_io.cc" # from [046023a08a66429c7f47f607fd2b32fe51341b5c] # to [5373a733961d78a573b98d3fab224963c27f548f] # # patch "file_io.hh" # from [ed405b7d81a539357342fc4f8d23cc70e1fd9a00] # to [73785d223213a9c2e85213a8667b9cc43ac4f4c4] # # patch "threads.hh" # from [6465442405723ea709b52bd87dc7afea45c3ac8f] # to [55eed692f768a5b6ed152cc0df66440c698765ad] # # patch "unix/threads.cc" # from [a52626b012472c01a272d31120cc6b00246c140d] # to [a9e6411256037c5a4713c796d08689289ba79ab8] # # patch "work.cc" # from [f20072cb28b21331f9964e582d5796b425b7f111] # to [4e0ff505885eb9ee1ec42745ed4c6ebd34fbefb6] # ============================================================ --- automate.cc f9b4f9ac8a7b375484336b4e13d80c39c3720e43 +++ automate.cc 8017e36c8cc1681d756239707e409b0d81881039 @@ -758,10 +758,10 @@ struct inventory_itemizer : public tree_ inventory_map & inventory; inodeprint_map ipm; workspace & work; - file_ident_pool & pool; + worker_pool & pool; inventory_itemizer(workspace & work, - file_ident_pool & pool, + worker_pool & pool, path_restriction const & m, inventory_map & i) : mask(m), inventory(i), work(work), pool(pool) @@ -819,7 +819,7 @@ inventory_filesystem(workspace & work, path_restriction const & mask, inventory_map & inventory) { - file_ident_pool pool; + worker_pool pool; inventory_itemizer itemizer(work, pool, mask, inventory); file_path const root; // The constructor file_path() returns ""; the root directory. walk_tree ============================================================ --- file_io.cc 046023a08a66429c7f47f607fd2b32fe51341b5c +++ file_io.cc 5373a733961d78a573b98d3fab224963c27f548f @@ -551,17 +551,15 @@ public: } }; -template class worker_pool; - bool -ident_existing_file(file_ident_pool & pool, shared_ptr p, +ident_existing_file(worker_pool & pool, shared_ptr p, shared_ptr ident) { return ident_existing_file(pool, p, ident, get_path_status(*p)); } bool -ident_existing_file(file_ident_pool & pool, shared_ptr p, +ident_existing_file(worker_pool & pool, shared_ptr p, shared_ptr ident, path::status status) { switch (status) @@ -575,7 +573,7 @@ ident_existing_file(file_ident_pool & po return false; } - pool.add_job(p, ident); + pool.add_job(new file_hash_calc_task(p, ident)); return true; } ============================================================ --- file_io.hh ed405b7d81a539357342fc4f8d23cc70e1fd9a00 +++ file_io.hh 73785d223213a9c2e85213a8667b9cc43ac4f4c4 @@ -125,12 +125,11 @@ class file_hash_calc_task; // a file_path as an input, and output a success indicator as well // as a file_id, in case of success. class file_hash_calc_task; -typedef worker_pool file_ident_pool; -bool ident_existing_file(file_ident_pool & pool, +bool ident_existing_file(worker_pool & pool, boost::shared_ptr p, boost::shared_ptr ident); -bool ident_existing_file(file_ident_pool & pool, +bool ident_existing_file(worker_pool & pool, boost::shared_ptr p, boost::shared_ptr ident, path::status status); ============================================================ --- threads.hh 6465442405723ea709b52bd87dc7afea45c3ac8f +++ threads.hh 55eed692f768a5b6ed152cc0df66440c698765ad @@ -19,32 +19,14 @@ public: virtual void operator()() = 0; }; -extern void create_thread_for(threaded_task * func); - -template class worker_pool { + int max_threads, num_threads; std::stack tstack; public: - worker_pool() - { }; - - void add_job(boost::shared_ptr in, boost::shared_ptr out) - { - I(in); - I(out); - tstack.push(new TASK(in, out)); - } - - void wait(void) - { - while (!tstack.empty()) - { - threaded_task *task = tstack.top(); - tstack.pop(); - create_thread_for(task); - } - } + worker_pool(); + void add_job(threaded_task* t); + void wait(); }; // Local Variables: ============================================================ --- unix/threads.cc a52626b012472c01a272d31120cc6b00246c140d +++ unix/threads.cc a9e6411256037c5a4713c796d08689289ba79ab8 @@ -59,6 +59,26 @@ create_thread_for(threaded_task * task) delete task; } +worker_pool::worker_pool() + : max_threads(4), + num_threads(0) +{ } + +void worker_pool::add_job(threaded_task* t) +{ + tstack.push(t); +} + +void worker_pool::wait(void) +{ + while (!tstack.empty()) + { + threaded_task *task = tstack.top(); + tstack.pop(); + create_thread_for(task); + } +} + // Local Variables: // mode: C++ // fill-column: 76 ============================================================ --- work.cc f20072cb28b21331f9964e582d5796b425b7f111 +++ work.cc 4e0ff505885eb9ee1ec42745ed4c6ebd34fbefb6 @@ -807,7 +807,7 @@ addition_builder::add_nodes_for(file_pat case path::file: { file_id ident; - file_ident_pool pool; // FIXME! + worker_pool pool; // FIXME! shared_ptr fpath(new file_path(path)); shared_ptr fid(new file_id()); I(ident_existing_file(pool, fpath, fid)); @@ -1336,7 +1336,7 @@ workspace::update_current_roster_from_fi return; node_map const & nodes = ros.all_nodes(); - file_ident_pool pool; + worker_pool pool; for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { node_id nid = i->first; @@ -1588,7 +1588,7 @@ workspace::perform_deletions(database & file_t file = downcast_to_file_t(n); shared_ptr fpath(new file_path(name)); shared_ptr fid(new file_id()); - file_ident_pool pool; // FIXME: speed this up! + worker_pool pool; // FIXME: speed this up! I(ident_existing_file(pool, fpath, fid)); pool.wait(); if (file->content == *fid)