RAUL  0.8.0
Maid.hpp
1 /* This file is part of Raul.
2  * Copyright (C) 2007-2009 David Robillard <http://drobilla.net>
3  *
4  * Raul is free software; you can redistribute it and/or modify it under the
5  * terms of the GNU General Public License as published by the Free Software
6  * Foundation; either version 2 of the License, or (at your option) any later
7  * version.
8  *
9  * Raul is distributed in the hope that it will be useful, but WITHOUT ANY
10  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16  */
17 
18 #ifndef RAUL_MAID_HPP
19 #define RAUL_MAID_HPP
20 
21 #include <boost/utility.hpp>
22 #include "raul/SharedPtr.hpp"
23 #include "raul/SRSWQueue.hpp"
24 #include "raul/Deletable.hpp"
25 #include "raul/List.hpp"
26 
27 namespace Raul {
28 
29 
46 class Maid : boost::noncopyable
47 {
48 public:
49  explicit Maid(size_t size);
50  ~Maid();
51 
55  inline void push(Raul::Deletable* obj) {
56  if (obj)
57  _objects.push(obj);
58  }
59 
60  void manage(SharedPtr<Raul::Deletable> ptr);
61 
62  void cleanup();
63 
64 private:
65  typedef Raul::SRSWQueue<Raul::Deletable*> Objects;
66  typedef Raul::List<SharedPtr<Raul::Deletable> > Managed;
67 
68  Objects _objects;
69  Managed _managed;
70 };
71 
72 
73 } // namespace Raul
74 
75 #endif // RAUL_MAID_HPP
76 
Something with a virtual destructor.
Definition: Deletable.hpp:28
bool push(const T &obj)
Push an item onto the back of the SRSWQueue - realtime-safe, not thread-safe.
Definition: SRSWQueue.hpp:130
Explicitly driven garbage collector.
Definition: Maid.hpp:46
Definition: Array.hpp:26
A realtime safe, (partially) thread safe doubly-linked list.
Definition: List.hpp:41
void push(Raul::Deletable *obj)
Push a raw pointer to be deleted when cleanup() is called next.
Definition: Maid.hpp:55
void manage(SharedPtr< Raul::Deletable > ptr)
Manage a SharedPtr.
Definition: Maid.cpp:41
void cleanup()
Free all the objects in the queue (passed by push()).
Definition: Maid.cpp:51