aboutsummaryrefslogtreecommitdiff
path: root/pdoctave_dataframe.h
blob: 53a21cc5e0b9b2ede836e10838cb0d29f2f05445 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef __pdoctave_data_frame_h__
#define __pdoctave_data_frame_h__

#ifdef __cplusplus
extern "C" {
#endif

#include <unistd.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/wait.h>
#include <stdio.h>

#include "pdoctave_datatypes.h"

#define STD_USLEEP_TIME 100
#define MAX_SLEEP_TIME 200000

typedef struct _SharedDataFrame_ SharedDataFrame;

struct _SharedDataFrame_ {
   int data_frame_id;

   int data_vec_id;
   int data_vec_len;
   int data_size_bytes;
   DatTyp data_typ;

   // internal states
   int frame_attached;
   int data_attached;

   int block_for_read;
   int block_for_write;
};

SharedDataFrame *newSharedDataFrame ();
SharedDataFrame *getSharedDataFrame (int id);
void freeSharedDataFrame (SharedDataFrame **sdf);
void removeSharedDataFrame (SharedDataFrame **sdf);
int getSharedDataFrameId (SharedDataFrame *sdf);

DatTyp getSharedDataType (SharedDataFrame *sdf);
int getSharedDataVecLength (SharedDataFrame *sdf);

void *newSharedData (SharedDataFrame *sdf, int n, int size_bytes, DatTyp dtyp);
void *getSharedData (SharedDataFrame *sdf);
void freeSharedData (SharedDataFrame *sdf, void **data);
void removeSharedData (SharedDataFrame *sdf, void **data);

void unBlockForReading (SharedDataFrame *sdf);
void unBlockForWriting (SharedDataFrame *sdf);
void blockForReading (SharedDataFrame *sdf);
void blockForWriting (SharedDataFrame *sdf);
void sleepUntilReadUnBlocked (SharedDataFrame *sdf, int usleep_time);
void sleepUntilReadBlocked (SharedDataFrame *sdf, int usleep_time);
void sleepUntilWriteUnBlocked (SharedDataFrame *sdf, int usleep_time);
void sleepUntilWriteBlocked (SharedDataFrame *sdf, int usleep_time);


#ifdef __cplusplus
}
#endif

#endif