Commit 41d7c81f authored by Arnaud Blanchard's avatar Arnaud Blanchard

Add semaphore management in C. Used for integration with python

parent f6fa4fe1
......@@ -146,6 +146,14 @@ typedef struct blc_channel
/** Wait until sommeone has read and acknoledged the data.
We use void * to make it ablle to be use in callback*/
void blc_channel_wait_ack_data(void *channel);
/** Indicates that new data is available
We use void * to make it ablle to be use in callback*/
void blc_channel_post_new_data(void *channel);
/** Indicates the data has been read.
We use void * to make it ablle to be use in callback*/
void blc_channel_post_ack_data(void *channel);
/**Used by EXIT_ON_CHANNEL_ERROR*/
......@@ -155,12 +163,16 @@ typedef struct blc_channel
Dims_nb is the number of dimenssions of the data ( 1 for a vector).
The following values are the the length of each dims. You must have the same number of length than dims_nb*/
///Alllocate and create blc_channel
blc_channel *blc_channel_new( const char *name, int mode, uint32_t type, uint32_t format, int dims_nb, int length0, ...);
///Destroys and free a blc_channel
void blc_channel_delete(blc_channel *channel);
///Returns a pointer to data
void *blc_channel_get_data(blc_channel *channel);
void blc_channel_create(blc_channel* channel, const char *name, int mode, uint32_t type, uint32_t format, int dims_nb, int length0, ...);
/**Open an exisiting channel 'name' */
void blc_channel_open(blc_channel* channel, const char *name, int mode);
......
......@@ -303,7 +303,19 @@ void blc_channel_wait_new_data(void *channel_pt){
void blc_channel_wait_ack_data(void *channel_pt){
blc_channel *channel=(blc_channel*)channel_pt;
SYSTEM_ERROR_CHECK(sem_wait(channel->sem_new_data), -1, "Waiting ack data for channel '%s'", channel->name);
SYSTEM_ERROR_CHECK(sem_wait(channel->sem_ack_data), -1, "Waiting ack data for channel '%s'", channel->name);
}
void blc_channel_post_new_data(void *channel_pt){
blc_channel *channel=(blc_channel*)channel_pt;
SYSTEM_ERROR_CHECK(sem_post(channel->sem_new_data), -1, "Posting new data for channel '%s'", channel->name);
}
void blc_channel_post_ack_data(void *channel_pt){
blc_channel *channel=(blc_channel*)channel_pt;
SYSTEM_ERROR_CHECK(sem_post(channel->sem_ack_data), -1, "Posting ack data for channel '%s'", channel->name);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment