Drizzled Public API Documentation

barriers.h
1 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2010 Brian Aker
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
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <boost/thread/mutex.hpp>
22 #include <boost/thread/condition_variable.hpp>
23 #include <boost/unordered_map.hpp>
24 #include <boost/unordered/unordered_set.hpp>
25 
26 #include <string>
27 
28 #include <drizzled/session.h>
29 #include <drizzled/util/string.h>
30 
31 
32 #pragma once
33 
34 namespace user_locks {
35 namespace barriers {
36 
37 const size_t LARGEST_BARRIER_NAME= 64;
38 
39 enum return_t {
40  SUCCESS,
41  NOT_FOUND,
42  NOT_OWNED_BY
43 };
44 
45 class Barriers
46 {
47 public:
48  typedef boost::unordered_map<user_locks::Key, Barrier::shared_ptr> Map;
49 
50  static Barriers &getInstance(void)
51  {
52  static Barriers instance;
53  return instance;
54  }
55 
56  bool create(const user_locks::Key &arg, drizzled::session_id_t owner);
57  bool create(const user_locks::Key &arg, drizzled::session_id_t owner, int64_t wait_count);
58  return_t release(const user_locks::Key &arg, drizzled::session_id_t owner);
59  Barrier::shared_ptr find(const user_locks::Key &arg);
60  void Copy(Map &arg);
61 
62 private:
63 
64  boost::mutex mutex;
65  Map barrier_map;
66 };
67 
68 
69 } /* namespace barriers */
70 } /* namespace user_locks */
71