Making use of the C++ structures in C only code feature introduced with
r34441. This allows to completely stick to FreeBSD's conditional cv_* function semantics as 'struct cv' variables are freed automatically now. This also gets rid of the dynamically de-/allocating of ConditionalVariables. Thank you Ingo for helping me through this. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34489 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,8 +11,6 @@ extern "C" {
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <condition_variable.h>
|
||||
|
||||
#include "Condvar.h"
|
||||
#include "device.h"
|
||||
|
||||
@@ -23,8 +21,7 @@ extern "C" {
|
||||
void
|
||||
conditionInit(struct cv* variable, const char* description)
|
||||
{
|
||||
variable->condition = new(std::nothrow) ConditionVariable();
|
||||
variable->condition->Init(variable, description);
|
||||
variable->condition.Init(variable, description);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,23 +29,21 @@ void
|
||||
conditionPublish(struct cv* variable, const void* waitChannel,
|
||||
const char* description)
|
||||
{
|
||||
variable->condition = new(std::nothrow) ConditionVariable();
|
||||
variable->condition->Publish(waitChannel, description);
|
||||
variable->condition.Publish(waitChannel, description);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
conditionUnpublish(const struct cv* variable)
|
||||
conditionUnpublish(struct cv* variable)
|
||||
{
|
||||
variable->condition->Unpublish();
|
||||
delete variable->condition;
|
||||
variable->condition.Unpublish();
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
conditionTimedWait(const struct cv* variable, const int timeout)
|
||||
conditionTimedWait(struct cv* variable, const int timeout)
|
||||
{
|
||||
status_t status = variable->condition->Wait(B_RELATIVE_TIMEOUT,
|
||||
status_t status = variable->condition.Wait(B_RELATIVE_TIMEOUT,
|
||||
ticks_to_usecs(timeout));
|
||||
|
||||
if (status != B_OK)
|
||||
@@ -58,16 +53,16 @@ conditionTimedWait(const struct cv* variable, const int timeout)
|
||||
|
||||
|
||||
void
|
||||
conditionWait(const struct cv* variable)
|
||||
conditionWait(struct cv* variable)
|
||||
{
|
||||
variable->condition->Wait();
|
||||
variable->condition.Wait();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
conditionNotifyOne(const struct cv* variable)
|
||||
conditionNotifyOne(struct cv* variable)
|
||||
{
|
||||
variable->condition->NotifyOne();
|
||||
variable->condition.NotifyOne();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ extern "C" {
|
||||
|
||||
void conditionInit(struct cv*, const char*);
|
||||
void conditionPublish(struct cv*, const void*, const char*);
|
||||
void conditionUnpublish(const struct cv*);
|
||||
int conditionTimedWait(const struct cv*, const int);
|
||||
void conditionWait(const struct cv*);
|
||||
void conditionNotifyOne(const struct cv*);
|
||||
void conditionUnpublish(struct cv*);
|
||||
int conditionTimedWait(struct cv*, const int);
|
||||
void conditionWait(struct cv*);
|
||||
void conditionNotifyOne(struct cv*);
|
||||
int publishedConditionTimedWait(const void*, const int);
|
||||
void publishedConditionNotifyAll(const void*);
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ UsePrivateHeaders net ;
|
||||
UsePrivateKernelHeaders ;
|
||||
UseHeaders $(HAIKU_PRIVATE_KERNEL_HEADERS) : true ;
|
||||
|
||||
# Enabling C++ structures in C only code
|
||||
Includes [ FGristFiles kernel_c++_structs.h ]
|
||||
: <src!system!kernel>kernel_c++_struct_sizes.h ;
|
||||
|
||||
SubDirCcFlags [ FDefines _KERNEL=1 ] ;
|
||||
|
||||
KernelStaticLibrary libfreebsd_network.a :
|
||||
|
||||
@@ -8,9 +8,17 @@
|
||||
|
||||
#include <sys/queue.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#include <kernel_c++_structs.h>
|
||||
extern "C" {
|
||||
#else
|
||||
#include <kernel_c++_structs.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct cv {
|
||||
struct ConditionVariable* condition;
|
||||
struct ConditionVariable condition;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user