-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexandr Kutuzov
committed
Sep 17, 2012
1 parent
75d5617
commit a5a2a6b
Showing
17 changed files
with
381 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "avcondition.h" | ||
|
||
AVCondition::AVCondition() : | ||
condition() | ||
{ | ||
pthread_cond_init(&condition, NULL); | ||
} | ||
|
||
AVCondition::~AVCondition() | ||
{ | ||
pthread_cond_destroy(&condition); | ||
} | ||
|
||
bool AVCondition::wait() | ||
{ | ||
pthread_cond_wait(&condition, &mutex); | ||
return true; | ||
} | ||
|
||
bool AVCondition::signal() | ||
{ | ||
pthread_cond_signal(&condition); | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef AVCONDITION_H | ||
#define AVCONDITION_H | ||
|
||
#include "avmutex.h" | ||
|
||
class AVCondition : public AVMutex | ||
{ | ||
public: | ||
explicit AVCondition(); | ||
virtual ~AVCondition(); | ||
|
||
bool wait(); | ||
bool signal(); | ||
|
||
protected: | ||
pthread_cond_t condition; | ||
}; | ||
|
||
#endif // AVCONDITION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "avmutex.h" | ||
|
||
AVMutex::AVMutex(): mutex() | ||
{ | ||
pthread_mutex_init(&mutex, NULL); | ||
} | ||
|
||
AVMutex::~AVMutex() | ||
{ | ||
pthread_mutex_destroy(&mutex); | ||
} | ||
|
||
bool AVMutex::lock() | ||
{ | ||
if (pthread_mutex_lock(&mutex) != 0) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
bool AVMutex::unlock() | ||
{ | ||
if (pthread_mutex_unlock(&mutex) != 0) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef AVMUTEX_H | ||
#define AVMUTEX_H | ||
|
||
#include <pthread.h> | ||
|
||
class AVMutex | ||
{ | ||
public: | ||
explicit AVMutex(); | ||
virtual ~AVMutex(); | ||
|
||
bool lock(); | ||
bool unlock(); | ||
|
||
protected: | ||
pthread_mutex_t mutex; | ||
}; | ||
|
||
#endif // AVMUTEX_H |
Oops, something went wrong.