source: libcfa/src/memory.hfa @ fee4436

Last change on this file since fee4436 was 031453c, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Forgot to change memory.hfa

  • Property mode set to 100644
File size: 2.8 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// memory.hfa -- Memory Management Tools for CFA
8//
9// Author           : Andrew Beach
10// Created On       : Tue Jun  2 16:48:00 2020
11// Last Modified By : Andrew Beach
12// Last Modified On : Fri Jan 29 15:52:00 2021
13// Update Count     : 1
14//
15
16#pragma once
17
18// Internal data object.
19forall(T & | sized(T))
20struct counter_data {
21        unsigned int counter;
22        T object;
23};
24
25forall(T & | sized(T), Args... | { void ?{}(T &, Args); })
26void ?{}(counter_data(T) & this, Args args);
27
28forall(T & | sized(T) | { void ^?{}(T &); })
29void ^?{}(counter_data(T) & this);
30
31// This is one of many pointers keeping this alive.
32forall(T & | sized(T))
33struct counter_ptr {
34        counter_data(T) * data;
35};
36
37forall(T & | sized(T))
38void ?{}(counter_ptr(T) & this);
39forall(T & | sized(T))
40void ?{}(counter_ptr(T) & this, zero_t);
41forall(T & | sized(T))
42void ?{}(counter_ptr(T) & this, counter_ptr(T) that);
43forall(T & | sized(T), Args... | { void ?{}(T&, Args); })
44void ?{}(counter_ptr(T) & this, Args args);
45
46forall(T & | sized(T) | { void ^?{}(T &); })
47void ^?{}(counter_ptr(T) & this);
48
49forall(T & | sized(T))
50T & *?(counter_ptr(T) & this);
51
52forall(T & | sized(T) | { void ^?{}(T &); })
53void ?=?(counter_ptr(T) & this, counter_ptr(T) that);
54forall(T & | sized(T) | { void ^?{}(T &); })
55void ?=?(counter_ptr(T) & this, zero_t);
56
57forall(T & | sized(T))
58int ?==?(counter_ptr(T) const & this, counter_ptr(T) const & that);
59forall(T & | sized(T))
60int ?!=?(counter_ptr(T) const & this, counter_ptr(T) const & that);
61forall(T & | sized(T))
62int ?==?(counter_ptr(T) const & this, zero_t);
63forall(T & | sized(T))
64int ?!=?(counter_ptr(T) const & this, zero_t);
65
66// This is the only pointer that keeps this alive.
67forall(T &)
68struct unique_ptr {
69        T * data;
70};
71
72forall(T &)
73void ?{}(unique_ptr(T) & this);
74forall(T &)
75void ?{}(unique_ptr(T) & this, zero_t);
76forall(T &)
77void ?{}(unique_ptr(T) & this, unique_ptr(T) that) = void;
78forall(T & | sized(T), Args... | { void ?{}(T &, Args); })
79void ?{}(unique_ptr(T) & this, Args args);
80
81forall(T & | { void ^?{}(T &); })
82void ^?{}(unique_ptr(T) & this);
83
84forall(T & )
85T & *?(unique_ptr(T) & this);
86
87forall(T &)
88void ?=?(unique_ptr(T) & this, unique_ptr(T) that) = void;
89forall(T & | { void ^?{}(T &); })
90void ?=?(unique_ptr(T) & this, zero_t);
91
92forall(T & | { void ^?{}(T &); })
93void move(unique_ptr(T) & this, unique_ptr(T) & that);
94
95forall(T &)
96T * release(unique_ptr(T) & this);
97
98forall(T &)
99int ?==?(unique_ptr(T) const & this, unique_ptr(T) const & that);
100forall(T &)
101int ?!=?(unique_ptr(T) const & this, unique_ptr(T) const & that);
102forall(T &)
103int ?==?(unique_ptr(T) const & this, zero_t);
104forall(T &)
105int ?!=?(unique_ptr(T) const & this, zero_t);
Note: See TracBrowser for help on using the repository browser.