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 */
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 lost
98 (*GNUNET_LOCKMANAGER_StatusCallback) (void *cls,
99 const char *domain_name,
101 enum GNUNET_LOCKMANAGER_Status
106 * Opaque handle to locking request
108 struct GNUNET_LOCKMANAGER_LockingRequest;
112 * Tries to acquire the given lock(even if the lock has been lost) until the
113 * request is called. If the lock is available the status_cb will be
114 * called. If the lock is busy then the request is queued and status_cb
115 * will be called when the lock has been made available and acquired by us.
117 * @param handle the handle to the lockmanager service
119 * @param domain_name name of the locking domain. Clients who want to share
120 * locks must use the same name for the locking domain. Also the
121 * domain_name should be selected with the prefix
122 * "GNUNET_<PROGRAM_NAME>_" to avoid domain name collisions.
125 * @param lock which lock to lock
127 * @param status_cb the callback for signalling when the lock is acquired and
130 * @param status_cb_cls the closure to the above callback
132 * @return the locking request handle for this request. It will be invalidated
133 * when status_cb is called.
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 us then the lock is
147 * 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 */