### Avant 1.0
###
-- renomages
- gras_os_time
- gras_os_sleep
- gras_os_getload
+- gras_os_getload
- gras_datadesc_import_nws
BEGIN_DECL
/**
- * gras_time:
+ * gras_os_time:
*
* Get the time in number of second since the Epoch.
* (00:00:00 UTC, January 1, 1970 in Real Life, and begining of simulation in SG)
*/
-double gras_time(void);
+double gras_os_time(void);
/**
- * gras_sleep:
+ * gras_os_sleep:
* @sec: number of seconds to sleep
* @usec: number of microseconds to sleep
*
* sleeps for the given amount of seconds plus the given amount of microseconds.
*/
-void gras_sleep(unsigned long sec, unsigned long usec);
+void gras_os_sleep(unsigned long sec, unsigned long usec);
END_DECL
*/
gras_error_t
gras_msgtype_declare(const char *name,
- gras_datadesc_type_t *payload,
- gras_msgtype_t **dst) {
- return gras_msgtype_declare_v(name, 0, payload, dst);
+ gras_datadesc_type_t *payload) {
+ return gras_msgtype_declare_v(name, 0, payload);
}
/**
gras_error_t
gras_msgtype_declare_v(const char *name,
short int version,
- gras_datadesc_type_t *payload,
- gras_msgtype_t **dst) {
+ gras_datadesc_type_t *payload) {
gras_error_t errcode;
gras_msgtype_t *msgtype;
TRY(gras_set_add(_gras_msgtype_set, (gras_set_elm_t*)msgtype,
&gras_msgtype_free));
-
+
return no_error;
}
VERB1("Waiting for message %s",msgt_want->name);
- start = now = gras_time();
+ start = now = gras_os_time();
gras_dynar_foreach(pd->msg_queue,cpt,msg){
if (msg.type->code == msgt_want->code) {
msg.payload_size = payload_size_got;
TRY(gras_dynar_push(pd->msg_queue,&msg));
- now=gras_time();
+ now=gras_os_time();
if (now - start + 0.001 < timeout) {
RAISE1(timeout_error,"Timeout while waiting for msg %s",msgt_want->name);
}
gras_error_t errcode;
gras_dynar_t *sockets= gras_socketset_get();
int done = -1;
- double wakeup = gras_time() + 1000000*timeout;
+ double wakeup = gras_os_time() + 1000000*timeout;
double now = 0;
/* nextToService used to make sure socket with high number do not starve */
// static int nextToService = 0;
*dst=NULL;
while (done == -1) {
if (timeout > 0) { /* did we timeout already? */
- now = gras_time();
+ now = gras_os_time();
if (now == -1 || now >= wakeup) {
done = 0; /* didn't find anything */
break;
gras_socket_t **dst) {
gras_error_t errcode;
- double startTime=gras_time();
+ double startTime=gras_os_time();
gras_procdata_t *pd=gras_procdata_get();
gras_trp_sg_sock_data_t *sockdata;
gras_trp_plugin_t *trp;
// MSG_process_sleep(1);
MSG_process_sleep(0.01);
}
- } while (gras_time()-startTime < timeout
+ } while (gras_os_time()-startTime < timeout
|| MSG_task_Iprobe((m_channel_t) pd->chan));
return timeout_error;
#include "gras_private.h"
#include <sys/time.h> /* gettimeofday() */
-double gras_time() {
+double gras_os_time() {
struct timeval tv;
gettimeofday(&tv, NULL);
return (double)(tv.tv_sec * 1000000 + tv.tv_usec);
}
-void gras_sleep(unsigned long sec,unsigned long usec) {
+void gras_os_sleep(unsigned long sec,unsigned long usec) {
sleep(sec);
if (usec/1000000) sleep(usec/1000000);
#include "Virtu/virtu_sg.h"
-double gras_time() {
+/**
+ * gras_time:
+ * @Returns: The current time
+ *
+ * The epoch since when the time is given is not specified. It is thus only usefull to compute intervals
+ */
+double gras_os_time() {
return MSG_getClock();
}
-
-void gras_sleep(unsigned long sec,unsigned long usec) {
+
+/**
+ * gras_sleep:
+ * @sec: amount of sec to sleep
+ * @usec: amount of micro second to sleep
+ *
+ * Freeze the process for the specified amount of time
+ */
+void gras_os_sleep(unsigned long sec,unsigned long usec) {
MSG_process_sleep((double)sec + ((double)usec)/1000000);
}