A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update Doc.
[simgrid.git]
/
doc
/
gtut-files
/
07-timers.c
diff --git
a/doc/gtut-files/07-timers.c
b/doc/gtut-files/07-timers.c
index
6622034
..
cb5ad51
100644
(file)
--- a/
doc/gtut-files/07-timers.c
+++ b/
doc/gtut-files/07-timers.c
@@
-1,3
+1,9
@@
+/* Copyright (c) 2006, 2007, 2009, 2010. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
#include <gras.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
#include <gras.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(test,"My little example");
@@
-16,7
+22,7
@@
int server_kill_cb(gras_msg_cb_ctx_t ctx, void *payload) {
globals->killed = 1;
globals->killed = 1;
- return
1
;
+ return
0
;
} /* end_of_kill_callback */
int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
} /* end_of_kill_callback */
int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
@@
-25,7
+31,7
@@
int server_hello_cb(gras_msg_cb_ctx_t ctx, void *payload) {
INFO2("Cool, we received the message from %s:%d.",
gras_socket_peer_name(client), gras_socket_peer_port(client));
INFO2("Cool, we received the message from %s:%d.",
gras_socket_peer_name(client), gras_socket_peer_port(client));
- return
1
;
+ return
0
;
} /* end_of_hello_callback */
int server(int argc, char *argv[]) {
} /* end_of_hello_callback */
int server(int argc, char *argv[]) {
@@
-41,8
+47,8
@@
int server(int argc, char *argv[]) {
gras_msgtype_declare("kill", NULL);
mysock = gras_socket_server(atoi(argv[1]));
gras_msgtype_declare("kill", NULL);
mysock = gras_socket_server(atoi(argv[1]));
- gras_cb_register(
gras_msgtype_by_name("hello")
,&server_hello_cb);
- gras_cb_register(
gras_msgtype_by_name("kill")
,&server_kill_cb);
+ gras_cb_register(
"hello"
,&server_hello_cb);
+ gras_cb_register(
"kill"
,&server_kill_cb);
while (!globals->killed) {
gras_msg_handle(60);
while (!globals->killed) {
gras_msg_handle(60);
@@
-63,14
+69,14
@@
typedef struct {
void client_do_hello(void) {
client_data_t *globals=(client_data_t*)gras_userdata_get();
void client_do_hello(void) {
client_data_t *globals=(client_data_t*)gras_userdata_get();
- gras_msg_send(globals->toserver,
gras_msgtype_by_name("hello")
, NULL);
+ gras_msg_send(globals->toserver,
"hello"
, NULL);
INFO0("Hello sent to server");
} /* end_of_client_do_hello */
void client_do_stop(void) {
client_data_t *globals=(client_data_t*)gras_userdata_get();
INFO0("Hello sent to server");
} /* end_of_client_do_hello */
void client_do_stop(void) {
client_data_t *globals=(client_data_t*)gras_userdata_get();
- gras_msg_send(globals->toserver,
gras_msgtype_by_name("kill")
, NULL);
+ gras_msg_send(globals->toserver,
"kill"
, NULL);
INFO0("Kill sent to server");
gras_timer_cancel_repeat(0.5,client_do_hello);
INFO0("Kill sent to server");
gras_timer_cancel_repeat(0.5,client_do_hello);
@@
-91,7
+97,7
@@
int client(int argc, char *argv[]) {
VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
VERB1("Client ready; listening on %d", gras_socket_my_port(mysock));
- globals=gras_userdata_new(
server
_data_t*);
+ globals=gras_userdata_new(
client
_data_t*);
globals->done = 0;
gras_os_sleep(1.5); /* sleep 1 second and half */
globals->done = 0;
gras_os_sleep(1.5); /* sleep 1 second and half */