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 * @param domain_name the name of the locking domain. If the locking domain
50 * isn't existing in the service it will be created. Clients who want
51 * to share locks must use the same name for the locking domain
53 * @return upon success the handle to the service; NULL upon error
55 struct GNUNET_LOCKMANAGER_Handle *
56 GNUNET_LOCKMANAGER_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
57 const char *domain_name);
61 * Disconnect from the lockmanager service
63 * @param handle the handle to the lockmanager service
66 GNUNET_LOCKMANAGER_disconnect (struct GNUNET_LOCKMANAGER_Handle *handle);
70 * This callback will be called after a locking operation has been
71 * attempted. This callback will not be called when the LockingRequest has been
74 * @param cls the closure from GNUNET_LOCKMANAGER_lock call
75 * @param lock the lock for which has been locked successfully
77 typedef void (*GNUNET_LOCKMANAGER_CompletionCallback) (void *cls,
82 * Opaque handle to locking request
84 struct GNUNET_LOCKMANAGER_LockingRequest;
88 * Tries to lock the given lock
90 * @param handle the handle to the lockmanager service
91 * @param lock which lock to lock
92 * @param completion_cb the callback to be called when locking is successful
93 * @param completion_cb_cls the closure to the above callback
95 * @return the locking request handle for this request. It will be invalidated
96 * when completion_cb is called.
98 struct GNUNET_LOCKMANAGER_LockingRequest *
99 GNUNET_LOCKMANAGER_try_lock (struct GNUNET_LOCKMANAGER_Handle *handle,
101 GNUNET_LOCKMANAGER_CompletionCallback
103 void *completion_cb_cls);
107 * Function to cancel the locking request generated by
108 * GNUNET_LOCKMANAGER_try_lock. This should be used on a LockingRequest before
109 * the completion_cb for the associated lock is called.
111 * @param request the LockingRequest to cancel
114 GNUNET_LOCKMANAGER_cancel_request (struct GNUNET_LOCKMANAGER_LockingRequest
119 * Unlocks a lock which was locked by us. It does nothing when called on a lock
120 * which wasn't locked or was locked by someone else.
122 * @param handle the handle to the lockmanager service
123 * @param lock which lock to unlock
126 GNUNET_LOCKMANAGER_unlock (const struct GNUNET_LOCKMANAGER_Handle *handle,
130 #if 0 /* keep Emacsens' auto-indent happy */
137 /* ifndef GNUNET_LOCKMANAGER_SERVICE_H */
139 /* end of gnunet_lockmanager_service.h */