drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
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 <unordered_map>
24#include <unordered_set>
25
26#include <string>
27
28#include <drizzled/session.h>
29#include <drizzled/util/string.h>
30
31
32#pragma once
33
34namespace user_locks {
35namespace barriers {
36
37const size_t LARGEST_BARRIER_NAME= 64;
38
39enum return_t {
40 SUCCESS,
41 NOT_FOUND,
42 NOT_OWNED_BY
43};
44
46{
47public:
48 typedef std::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
62private:
63
64 boost::mutex mutex;
65 Map barrier_map;
66};
67
68
69} /* namespace barriers */
70} /* namespace user_locks */
71