paludis Version 3.0.2
The one true package mangler
executor.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2009, 2010, 2011, 2012 Ciaran McCreesh
5 *
6 * This file is part of the Paludis package manager. Paludis is free software;
7 * you can redistribute it and/or modify it under the terms of the GNU General
8 * Public License version 2, as published by the Free Software Foundation.
9 *
10 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef PALUDIS_GUARD_PALUDIS_UTIL_EXECUTOR_HH
21#define PALUDIS_GUARD_PALUDIS_UTIL_EXECUTOR_HH 1
22
23#include <paludis/util/executor-fwd.hh>
24#include <paludis/util/pimp.hh>
26#include <memory>
27#include <mutex>
28#include <string>
29
30namespace paludis
31{
33 {
34 public:
35 virtual ~Executive() = 0;
36
37 virtual std::string queue_name() const = 0;
38 virtual std::string unique_id() const = 0;
39 virtual bool can_run() const = 0;
40
41 virtual void pre_execute_exclusive() = 0;
42 virtual void execute_threaded() = 0;
43 virtual void flush_threaded() = 0;
44 virtual void post_execute_exclusive() = 0;
45 };
46
47 class PALUDIS_VISIBLE Executor
48 {
49 private:
50 Pimp<Executor> _imp;
51
52 void _one(const std::shared_ptr<Executive>);
53
54 public:
55 explicit Executor(const int ms_update_interval = 1000);
56 ~Executor();
57
58 int pending() const;
59 int active() const;
60 int done() const;
61
62 void add(const std::shared_ptr<Executive> & x);
63
64 void execute();
65
66 std::mutex & exclusivity_mutex() PALUDIS_ATTRIBUTE((warn_unused_result));
67 };
68
69 extern template class Pimp<Executor>;
70}
71
72#endif
Definition executor.hh:33
Definition pimp.hh:52
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24