cppthread 1.1.16
C++ Thread Library
item_with_predicate.h
Go to the documentation of this file.
1// Copyright (c) 2013-2025 Made to Order Software Corp. All Rights Reserved
2//
3// https://snapwebsites.org/project/cppthread
4// contact@m2osw.com
5//
6// This program is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation; either version 2 of the License, or
9// (at your option) any later version.
10//
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License along
17// with this program; if not, write to the Free Software Foundation, Inc.,
18// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19#pragma once
20
32// self
33//
34#include <cppthread/mutex.h>
35
36
37// C++
38//
39#include <deque>
40
41
42
43namespace cppthread
44{
45
46
47
49{
50public:
51 typedef std::shared_ptr<item_with_predicate>
53 typedef std::weak_ptr<item_with_predicate>
55 typedef std::deque<weak_pointer_t>
57
59 item_with_predicate(dependencies_t const & dependencies);
60 virtual ~item_with_predicate();
61
62 void add_dependency(pointer_t dependency);
63 void add_dependencies(dependencies_t const & dependencies);
64 virtual bool valid_workload() const;
65
66private:
67 mutable mutex f_mutex = mutex();
69 mutable bool f_processing = false;
70};
71
72
73
74} // namespace cppthread
75// vim: ts=4 sw=4 et
A runner augmentation allowing for worker threads.
virtual ~item_with_predicate()
The destructor of the item with predicate.
bool f_processing
Whether this workload is being processed.
virtual bool valid_workload() const
The valid_workload() to test whether we can process this item.
void add_dependencies(dependencies_t const &dependencies)
Add a set of dependencies at once.
std::shared_ptr< item_with_predicate > pointer_t
The item_with_predicate shared pointer type.
mutex f_mutex
The mutex used to protect the predicate variables.
std::deque< weak_pointer_t > dependencies_t
The type representing the list of dependencies.
dependencies_t f_dependencies
Set of dependencies.
void add_dependency(pointer_t dependency)
Add an item as a predicate of this item.
std::weak_ptr< item_with_predicate > weak_pointer_t
The item_with_predicate weak pointer type.
A mutex object to ensures atomicity.
Definition mutex.h:55
Thread Runner and Managers.

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.