grapes / include / cloud_helper_utils.h @ master
History | View | Annotate | Download (2.13 KB)
1 | b71e9607 | Andrea Zito | /*
|
---|---|---|---|
2 | * Copyright (c) 2010 Andrea Zito
|
||
3 | *
|
||
4 | * This is free software; see lgpl-2.1.txt
|
||
5 | */
|
||
6 | |||
7 | #ifndef CLOUD_HELPER_UTILS_H
|
||
8 | #define CLOUD_HELPER_UTILS_H
|
||
9 | |||
10 | #include "cloud_helper.h" |
||
11 | #include "net_helper.h" |
||
12 | |||
13 | #define DATA_SOURCE_NONE 0 |
||
14 | #define DATA_SOURCE_NET 1 |
||
15 | #define DATA_SOURCE_CLOUD 2 |
||
16 | |||
17 | /**
|
||
18 | * @file cloud_helper_utils.h
|
||
19 | *
|
||
20 | * @brief Utilities function for managing cloud communications
|
||
21 | *
|
||
22 | * This files provides some utilities functions that simplifies
|
||
23 | * managing the addition of the cloud layer to the architecture
|
||
24 | *
|
||
25 | */
|
||
26 | |||
27 | /**
|
||
28 | * @brief Wait for data from peers and cloud via thread
|
||
29 | *
|
||
30 | * This function handles the waiting for data by peers and cloud
|
||
31 | * in a threaded way, hiding the need to manually managing threads.
|
||
32 | *
|
||
33 | * @param[in] n A pointer to the nodeID for which waiting data
|
||
34 | * @param[in] cloud A pointer to the cloud_helper_context for which
|
||
35 | * waiting data
|
||
36 | * @param[in] tout The timeout for the waiting
|
||
37 | * @param[in] user_fds A pointer to an optional array of file
|
||
38 | * descriptior to monitor
|
||
39 | * @param[out] data_source A pointer which will be used to store the
|
||
40 | * source for the data
|
||
41 | * @return 1 if data was available, 0 otherwise
|
||
42 | */
|
||
43 | int wait4any_threaded(struct nodeID *n, struct cloud_helper_context *cloud, struct timeval *tout, int *user_fds, int *data_source); |
||
44 | |||
45 | |||
46 | /**
|
||
47 | * @brief Wait for data from peers and cloud in a polling scheme
|
||
48 | *
|
||
49 | * This function handles the waiting for data by peers and cloud
|
||
50 | * by repeatedly waiting for a small time on each reasource.
|
||
51 | *
|
||
52 | * @param[in] n A pointer to the nodeID for which waiting data
|
||
53 | * @param[in] cloud A pointer to the cloud_helper_context for which
|
||
54 | * waiting data
|
||
55 | * @param[in] tout The timeout for the waiting
|
||
56 | * @param[in] step_tout The time to spend waiting in each step. If
|
||
57 | * NULL default is 100 milliseconds
|
||
58 | * @param[in] user_fds A pointer to an optional array of file
|
||
59 | * descriptior to monitor
|
||
60 | * @param[out] data_source A pointer which will be used to store the
|
||
61 | * source for the data
|
||
62 | * @return 1 if data was available, 0 otherwise
|
||
63 | */
|
||
64 | int wait4any_polling(struct nodeID *n, struct cloud_helper_context *cloud, struct timeval *tout, struct timeval *step_tout, int *user_fds, int *data_source); |
||
65 | |||
66 | #endif |