Changeset 15 in flair-src for trunk/lib/FlairCore/src/Mutex_impl.cpp


Ignore:
Timestamp:
04/08/16 15:40:57 (6 years ago)
Author:
Bayard Gildas
Message:

sources reformatted with flair-format-dir script

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairCore/src/Mutex_impl.cpp

    r2 r15  
    2323using namespace flair::core;
    2424
    25 Mutex_impl::Mutex_impl(Mutex *self)
    26 {
    27     this->self=self;
     25Mutex_impl::Mutex_impl(Mutex *self) {
     26  this->self = self;
    2827#ifdef __XENO__
    29     int status=rt_mutex_create(&mutex,NULL);
    30     if(status!=0) self->Err("rt_mutex_create error (%s)\n",strerror(-status));
     28  int status = rt_mutex_create(&mutex, NULL);
     29  if (status != 0)
     30    self->Err("rt_mutex_create error (%s)\n", strerror(-status));
    3131#else
    32     //flag_locked=false;//revoir l'implementation nrt du is_locked
    33     pthread_mutexattr_t attr;
    34     if(pthread_mutexattr_init(&attr)!=0)
    35     {
    36         self->Err("pthread_mutexattr_init error\n");
    37     }
    38     if(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0)
    39     {
    40         self->Err("pthread_mutexattr_settype error\n");
    41     }
    42     if(pthread_mutex_init(&mutex, &attr)!=0)
    43     {
    44         self->Err("pthread_mutex_init error\n");
    45     }
    46     if(pthread_mutexattr_destroy(&attr)!=0)
    47     {
    48         self->Err("pthread_mutexattr_destroy error\n");
    49     }
     32  // flag_locked=false;//revoir l'implementation nrt du is_locked
     33  pthread_mutexattr_t attr;
     34  if (pthread_mutexattr_init(&attr) != 0) {
     35    self->Err("pthread_mutexattr_init error\n");
     36  }
     37  if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) {
     38    self->Err("pthread_mutexattr_settype error\n");
     39  }
     40  if (pthread_mutex_init(&mutex, &attr) != 0) {
     41    self->Err("pthread_mutex_init error\n");
     42  }
     43  if (pthread_mutexattr_destroy(&attr) != 0) {
     44    self->Err("pthread_mutexattr_destroy error\n");
     45  }
    5046#endif
    5147}
    5248
    53 Mutex_impl::~Mutex_impl()
    54 {
    55     int status;
     49Mutex_impl::~Mutex_impl() {
     50  int status;
    5651#ifdef __XENO__
    57     status=rt_mutex_delete(&mutex);
     52  status = rt_mutex_delete(&mutex);
    5853#else
    59     status=pthread_mutex_destroy(&mutex);
     54  status = pthread_mutex_destroy(&mutex);
    6055#endif
    61     if(status!=0) self->Err("error destroying mutex (%s)\n",strerror(-status));
     56  if (status != 0)
     57    self->Err("error destroying mutex (%s)\n", strerror(-status));
    6258}
    6359
    64 void Mutex_impl::GetMutex(void)
    65 {
    66     int status;
     60void Mutex_impl::GetMutex(void) {
     61  int status;
    6762#ifdef __XENO__
    68     status=rt_mutex_acquire(&mutex,TM_INFINITE);
     63  status = rt_mutex_acquire(&mutex, TM_INFINITE);
    6964#else
    70     //flag_locked=true;
    71     status=pthread_mutex_lock(&mutex);
     65  // flag_locked=true;
     66  status = pthread_mutex_lock(&mutex);
    7267#endif
    73     if(status!=0) self->Err("error (%s)\n",strerror(-status));
     68  if (status != 0)
     69    self->Err("error (%s)\n", strerror(-status));
    7470}
    7571
    76 void Mutex_impl::ReleaseMutex(void)
    77 {
    78     int status;
     72void Mutex_impl::ReleaseMutex(void) {
     73  int status;
    7974#ifdef __XENO__
    80     status=rt_mutex_release(&mutex);
     75  status = rt_mutex_release(&mutex);
    8176#else
    82     status=pthread_mutex_unlock(&mutex);
    83     //flag_locked=false;
     77  status = pthread_mutex_unlock(&mutex);
     78// flag_locked=false;
    8479#endif
    85     if(status!=0) self->Err("error (%s)\n",strerror(-status));
     80  if (status != 0)
     81    self->Err("error (%s)\n", strerror(-status));
    8682}
    8783
     
    9288    RT_MUTEX_INFO info;
    9389    int status=rt_mutex_inquire(&mutex_rt,&info);
    94     if(status!=0) mutex->Err("erreur rt_mutex_inquire (%s)\n",strerror(-status));
     90    if(status!=0) mutex->Err("erreur rt_mutex_inquire
     91(%s)\n",strerror(-status));
    9592    if(info.locked>0) return true;
    9693    return false;
Note: See TracChangeset for help on using the changeset viewer.