diff options
author | Martin Nagy <mnagy@redhat.com> | 2008-12-10 21:25:39 +0100 |
---|---|---|
committer | Martin Nagy <mnagy@redhat.com> | 2008-12-10 21:25:39 +0100 |
commit | 84f3ee86191e15d70c7466cebe3d1fb34cf7e9d5 (patch) | |
tree | 1d6b9c7c65f0813dc90db59f56b57c1b79b2de79 /semaphore.h | |
download | ldap_driver_testing-84f3ee86191e15d70c7466cebe3d1fb34cf7e9d5.tar.gz ldap_driver_testing-84f3ee86191e15d70c7466cebe3d1fb34cf7e9d5.tar.xz ldap_driver_testing-84f3ee86191e15d70c7466cebe3d1fb34cf7e9d5.zip |
Initial import.
The driver for now only prints the argument list and then fails.
Diffstat (limited to 'semaphore.h')
-rw-r--r-- | semaphore.h | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/semaphore.h b/semaphore.h new file mode 100644 index 0000000..6c349e4 --- /dev/null +++ b/semaphore.h @@ -0,0 +1,45 @@ +/* Authors: Martin Nagy <mnagy@redhat.com> + * + * Copyright (C) 2008 Red Hat + * see file 'COPYING' for use and warranty information + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; version 2 only + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _LDAP_SEMAPHORE_H_ +#define _LDAP_SEMAPHORE_H_ + +#include <isc/condition.h> +#include <isc/mutex.h> + +/* + * Semaphore can be "acquired" multiple times. However, it has a maximum + * number of times someone can acquire him. If a semaphore is already acquired + * more times than allowed, it will block until other thread release its, + */ +struct semaphore { + int value; /* Maximum number of times you can LOCK()) */ + isc_mutex_t mutex; /* Mutex protecting this whole struct. */ + isc_condition_t cond; /* Condition used for waiting on release. */ +}; + +typedef struct semaphore semaphore_t; + +/* Public functions. */ +isc_result_t semaphore_init(semaphore_t *sem, int value); +void semaphore_destroy(semaphore_t *sem); +void semaphore_wait(semaphore_t *sem); +void semaphore_signal(semaphore_t *sem); + +#endif /* !_LDAP_SEMAPHORE_H_ */ |