Home | History | Annotate | Download | only in libtiutils
      1 /*
      2  * Copyright (C) Texas Instruments - http://www.ti.com/
      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 <utils/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 
     27 namespace android {
     28 
     29 class Semaphore
     30 {
     31 public:
     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 
     54 private:
     55     sem_t *mSemaphore;
     56 
     57 };
     58 
     59 };
     60