summaryrefslogtreecommitdiff
path: root/utils/Semaphore.h (plain)
blob: 3b4b68f6cdaf5f80da80918c1fb8eb7084b87895
1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18
19#include <Errors.h>
20#include <semaphore.h>
21#include <stdio.h>
22#include <stdarg.h>
23#include <stdlib.h>
24#include <string.h>
25#include <unistd.h>
26
27namespace android {
28
29class Semaphore
30{
31public:
32
33 Semaphore();
34 ~Semaphore();
35
36 //Release semaphore
37 status_t Release();
38
39 ///Create the semaphore with initial count value
40 status_t Create(int count=0);
41
42 ///Wait operation
43 status_t Wait();
44
45 ///Signal operation
46 status_t Signal();
47
48 ///Current semaphore count
49 int Count();
50
51 ///Wait operation with a timeout
52 status_t WaitTimeout(int timeoutMicroSecs);
53
54private:
55 sem_t *mSemaphore;
56
57};
58
59};
60