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 2, 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 */
39 * Opaque handle for the lockmanager service
41 struct GNUNET_LOCKMANAGER_Handle;
45 * Connect to the lockmanager service
47 * @param cfg the configuration to use
49 * @return upon success the handle to the service; NULL upon error
51 struct GNUNET_LOCKMANAGER_Handle *
52 GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg);
56 * Disconnect from the lockmanager service
58 * @param handle the handle to the lockmanager service
61 GNUNET_LOCKMANAGER_disconnect (struct GNUNET_LOCKMANAGER_Handle *handle);
65 * Enumeration for status
67 enum GNUNET_LOCKMANAGER_Status
70 * Signifies a successful operation
72 GNUNET_LOCKMANAGER_SUCCESS = 1,
75 * Used to signal that a lock is no longer valid. It must then be released
77 GNUNET_LOCKMANAGER_RELEASE
82 * This callback will be called when a lock has been successfully acquired or
83 * when an acquired lock has been lost (happens when the lockmanager service
86 * @param cls the closure from GNUNET_LOCKMANAGER_lock call
88 * @param domain_name the locking domain of the lock
90 * @param lock the lock for which this status is relevant
92 * @param status GNUNET_LOCKMANAGER_SUCCESS if the lock has been successfully
93 * acquired; GNUNET_LOCKMANAGER_RELEASE when the acquired lock is lost
96 (*GNUNET_LOCKMANAGER_StatusCallback) (void *cls,
97 const char *domain_name,
99 enum GNUNET_LOCKMANAGER_Status
104 * Opaque handle to locking request
106 struct GNUNET_LOCKMANAGER_LockingRequest;
110 * Tries to acquire the given lock(even if the lock has been lost) until the
111 * request is called. If the lock is available the status_cb will be
112 * called. If the lock is busy then the request is queued and status_cb
113 * will be called when the lock has been made available and acquired by us.
115 * @param handle the handle to the lockmanager service
117 * @param domain_name name of the locking domain. Clients who want to share
118 * locks must use the same name for the locking domain. Also the
119 * domain_name should be selected with the prefix
120 * "GNUNET_<PROGRAM_NAME>_" to avoid domain name collisions.
123 * @param lock which lock to lock
125 * @param status_cb the callback for signalling when the lock is acquired and
128 * @param status_cb_cls the closure to the above callback
130 * @return the locking request handle for this request. It will be invalidated
131 * when status_cb is called.
133 struct GNUNET_LOCKMANAGER_LockingRequest *
134 GNUNET_LOCKMANAGER_acquire_lock (struct GNUNET_LOCKMANAGER_Handle *handle,
135 const char *domain_name,
137 GNUNET_LOCKMANAGER_StatusCallback
139 void *status_cb_cls);
143 * Function to cancel the locking request generated by
144 * GNUNET_LOCKMANAGER_acquire_lock. If the lock is acquired us then the lock is
145 * released. GNUNET_LOCKMANAGER_StatusCallback will not be called upon any
146 * status changes resulting due to this call.
148 * @param request the LockingRequest to cancel
151 GNUNET_LOCKMANAGER_cancel_request (struct GNUNET_LOCKMANAGER_LockingRequest
155 #if 0 /* keep Emacsens' auto-indent happy */
162 /* ifndef GNUNET_LOCKMANAGER_SERVICE_H */
164 /* end of gnunet_lockmanager_service.h */