summaryrefslogtreecommitdiffstats
path: root/src/libixion/calc_status.hpp
blob: fc2512165138c1d75e228f316abc7579fb5982a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#ifndef INCLUDED_IXION_CALC_STATUS_HPP
#define INCLUDED_IXION_CALC_STATUS_HPP

#include "ixion/formula_result.hpp"

#include <mutex>
#include <condition_variable>

#include <boost/intrusive_ptr.hpp>

namespace ixion {

struct calc_status
{
    calc_status(const calc_status&) = delete;
    calc_status& operator=(const calc_status&) = delete;

    std::mutex mtx;
    std::condition_variable cond;
    std::unique_ptr<formula_result> result;

    const rc_size_t group_size;
    bool circular_safe;

    size_t refcount;

    calc_status();
    calc_status(const rc_size_t& _group_size);

    void add_ref();
    void release_ref();
};

inline void intrusive_ptr_add_ref(calc_status* p)
{
    p->add_ref();
}

inline void intrusive_ptr_release(calc_status* p)
{
    p->release_ref();
}

using calc_status_ptr_t = boost::intrusive_ptr<calc_status>;

}

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */