2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
22 * @file include/gnunet_lockmanager_service.h
23 * @brief API for the lockmanger service
24 * @author Sree Harsha Totakura
27 #ifndef GNUNET_LOCKMANAGER_SERVICE_H
28 #define GNUNET_LOCKMANAGER_SERVICE_H
33 #if 0 /* keep Emacsens' auto-indent happy */
38 #include "gnunet_configuration_lib.h"
41 * Opaque handle for the lockmanager service
43 struct GNUNET_LOCKMANAGER_Handle;
47 * Connect to the lockmanager service
49 * @param cfg the configuration to use
51 * @return upon success the handle to the service; NULL upon error
53 struct GNUNET_LOCKMANAGER_Handle *
54 GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
58 * Disconnect from the lockmanager service
60 * @param handle the handle to the lockmanager service
63 GNUNET_LOCKMANAGER_disconnect (struct GNUNET_LOCKMANAGER_Handle *handle);
67 * Enumeration for status
69 enum GNUNET_LOCKMANAGER_Status
72 * Signifies a successful operation
74 GNUNET_LOCKMANAGER_SUCCESS = 1,
77 * Used to signal that a lock is no longer valid. It must then be released
79 GNUNET_LOCKMANAGER_RELEASE
84 * This callback will be called when a lock has been successfully acquired or
85 * when an acquired lock has been lost (happens when the lockmanager service
88 * @param cls the closure from GNUNET_LOCKMANAGER_lock call
90 * @param domain_name the locking domain of the lock
92 * @param lock the lock for which this status is relevant
94 * @param status GNUNET_LOCKMANAGER_SUCCESS if the lock has been successfully
95 * acquired; GNUNET_LOCKMANAGER_RELEASE when the acquired lock is
99 (*GNUNET_LOCKMANAGER_StatusCallback) (void *cls,
100 const char *domain_name,
102 enum GNUNET_LOCKMANAGER_Status
107 * Opaque handle to locking request
109 struct GNUNET_LOCKMANAGER_LockingRequest;
113 * Tries to acquire the given lock(even if the lock has been lost) until the
114 * request is called. If the lock is available the status_cb will be
115 * called. If the lock is busy then the request is queued and status_cb
116 * will be called when the lock has been made available and acquired by us.
118 * @param handle the handle to the lockmanager service
120 * @param domain_name name of the locking domain. Clients who want to share
121 * locks must use the same name for the locking domain. Also the
122 * domain_name should be selected with the prefix
123 * "GNUNET_<PROGRAM_NAME>_" to avoid domain name collisions.
126 * @param lock which lock to lock
128 * @param status_cb the callback for signalling when the lock is acquired and
131 * @param status_cb_cls the closure to the above callback
133 * @return the locking request handle for this request
135 struct GNUNET_LOCKMANAGER_LockingRequest *
136 GNUNET_LOCKMANAGER_acquire_lock (struct GNUNET_LOCKMANAGER_Handle *handle,
137 const char *domain_name,
139 GNUNET_LOCKMANAGER_StatusCallback
141 void *status_cb_cls);
145 * Function to cancel the locking request generated by
146 * GNUNET_LOCKMANAGER_acquire_lock. If the lock is acquired by us then the lock
147 * is released. GNUNET_LOCKMANAGER_StatusCallback will not be called upon any
148 * status changes resulting due to this call.
150 * @param request the LockingRequest to cancel
153 GNUNET_LOCKMANAGER_cancel_request (struct GNUNET_LOCKMANAGER_LockingRequest
157 #if 0 /* keep Emacsens' auto-indent happy */
164 /* ifndef GNUNET_LOCKMANAGER_SERVICE_H */
166 /* end of gnunet_lockmanager_service.h */