Permalink
Browse files

Code uses 'task' instead of 'thread'

  • Loading branch information...
hintjens committed Feb 27, 2011
1 parent 3e3c2de commit dd7677a8e26a2ed0ef99679ae2dd1a7ff95a863e
Showing with 39 additions and 25 deletions.
  1. +6 −3 examples/C/asyncsrv.c
  2. +6 −4 examples/C/lruqueue.c
  3. +6 −4 examples/C/lruqueue2.c
  4. +6 −4 examples/C/peering2.c
  5. +6 −4 examples/C/peering3.c
  6. +6 −4 examples/C/rtdealer.c
  7. +3 −2 examples/C/rtmama.c
View
@@ -15,7 +15,8 @@
// run several client tasks in parallel, each with a different random ID.
static void *
-client_task (void *args) {
+client_task (void *args)
+{
void *context = zmq_init (1);
void *client = zmq_socket (context, ZMQ_XREQ);
@@ -57,7 +58,8 @@ client_task (void *args) {
static void *server_worker (void *socket);
-void *server_task (void *args) {
+void *server_task (void *args)
+{
void *context = zmq_init (1);
// Frontend socket talks to clients over TCP
@@ -109,7 +111,8 @@ void *server_task (void *args) {
// times, with random delays between replies.
//
static void *
-server_worker (void *context) {
+server_worker (void *context)
+{
void *worker = zmq_socket (context, ZMQ_XREQ);
zmq_connect (worker, "inproc://backend");
View
@@ -24,7 +24,8 @@
// Basic request-reply client using REQ socket
//
static void *
-client_thread (void *args) {
+client_task (void *args)
+{
void *context = zmq_init (1);
void *client = zmq_socket (context, ZMQ_REQ);
s_set_id (client); // Makes tracing easier
@@ -43,7 +44,8 @@ client_thread (void *args) {
// Worker using REQ socket to do LRU routing
//
static void *
-worker_thread (void *args) {
+worker_task (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_REQ);
s_set_id (worker); // Makes tracing easier
@@ -89,12 +91,12 @@ int main (void)
int client_nbr;
for (client_nbr = 0; client_nbr < NBR_CLIENTS; client_nbr++) {
pthread_t client;
- pthread_create (&client, NULL, client_thread, NULL);
+ pthread_create (&client, NULL, client_task, NULL);
}
int worker_nbr;
for (worker_nbr = 0; worker_nbr < NBR_WORKERS; worker_nbr++) {
pthread_t worker;
- pthread_create (&worker, NULL, worker_thread, NULL);
+ pthread_create (&worker, NULL, worker_task, NULL);
}
// Logic of LRU loop
// - Poll backend always, frontend only if 1+ worker ready
View
@@ -25,7 +25,8 @@
// Basic request-reply client using REQ socket
//
static void *
-client_thread (void *args) {
+client_task (void *args)
+{
void *context = zmq_init (1);
void *client = zmq_socket (context, ZMQ_REQ);
s_set_id (client); // Makes tracing easier
@@ -45,7 +46,8 @@ client_thread (void *args) {
// Worker using REQ socket to do LRU routing
//
static void *
-worker_thread (void *args) {
+worker_task (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_REQ);
s_set_id (worker); // Makes tracing easier
@@ -79,12 +81,12 @@ int main (void)
int client_nbr;
for (client_nbr = 0; client_nbr < NBR_CLIENTS; client_nbr++) {
pthread_t client;
- pthread_create (&client, NULL, client_thread, NULL);
+ pthread_create (&client, NULL, client_task, NULL);
}
int worker_nbr;
for (worker_nbr = 0; worker_nbr < NBR_WORKERS; worker_nbr++) {
pthread_t worker;
- pthread_create (&worker, NULL, worker_thread, NULL);
+ pthread_create (&worker, NULL, worker_task, NULL);
}
// Logic of LRU loop
// - Poll backend always, frontend only if 1+ worker ready
View
@@ -24,7 +24,8 @@
// Request-reply client using REQ socket
//
static void *
-client_thread (void *args) {
+client_task (void *args)
+{
void *context = zmq_init (1);
void *client = zmq_socket (context, ZMQ_REQ);
zmq_connect (client, "ipc://localfe.ipc");
@@ -46,7 +47,8 @@ client_thread (void *args) {
// Worker using REQ socket to do LRU routing
//
static void *
-worker_thread (void *args) {
+worker_task (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_REQ);
zmq_connect (worker, "ipc://localbe.ipc");
@@ -122,13 +124,13 @@ int main (int argc, char *argv [])
int worker_nbr;
for (worker_nbr = 0; worker_nbr < NBR_WORKERS; worker_nbr++) {
pthread_t worker;
- pthread_create (&worker, NULL, worker_thread, NULL);
+ pthread_create (&worker, NULL, worker_task, NULL);
}
// Start local clients
int client_nbr;
for (client_nbr = 0; client_nbr < NBR_CLIENTS; client_nbr++) {
pthread_t client;
- pthread_create (&client, NULL, client_thread, NULL);
+ pthread_create (&client, NULL, client_task, NULL);
}
// Interesting part
View
@@ -27,7 +27,8 @@
// sleep for a random period.
//
static void *
-client_thread (void *args) {
+client_task (void *args)
+{
int rc;
void *context = zmq_init (1);
void *client = zmq_socket (context, ZMQ_REQ);
@@ -79,7 +80,8 @@ client_thread (void *args) {
// Worker using REQ socket to do LRU routing
//
static void *
-worker_thread (void *args) {
+worker_task (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_REQ);
int rc = zmq_connect (worker, "ipc://localbe.ipc");
@@ -171,13 +173,13 @@ int main (int argc, char *argv [])
int worker_nbr;
for (worker_nbr = 0; worker_nbr < NBR_WORKERS; worker_nbr++) {
pthread_t worker;
- pthread_create (&worker, NULL, worker_thread, NULL);
+ pthread_create (&worker, NULL, worker_task, NULL);
}
// Start local clients
int client_nbr;
for (client_nbr = 0; client_nbr < NBR_CLIENTS; client_nbr++) {
pthread_t client;
- pthread_create (&client, NULL, client_thread, NULL);
+ pthread_create (&client, NULL, client_task, NULL);
}
// Interesting part
View
@@ -18,7 +18,8 @@
// run on different boxes...
//
static void *
-worker_a (void *args) {
+worker_task_a (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_XREQ);
zmq_setsockopt (worker, ZMQ_IDENTITY, "A", 1);
@@ -42,7 +43,8 @@ worker_a (void *args) {
}
static void *
-worker_b (void *args) {
+worker_task_b (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_XREQ);
zmq_setsockopt (worker, ZMQ_IDENTITY, "B", 1);
@@ -74,8 +76,8 @@ int main (void)
zmq_bind (client, "ipc://routing.ipc");
pthread_t worker;
- pthread_create (&worker, NULL, worker_a, NULL);
- pthread_create (&worker, NULL, worker_b, NULL);
+ pthread_create (&worker, NULL, worker_task_a, NULL);
+ pthread_create (&worker, NULL, worker_task_b, NULL);
// Wait for threads to connect, since otherwise the messages
// we send won't be routable.
View
@@ -17,7 +17,8 @@
#define NBR_WORKERS 10
static void *
-worker_thread (void *args) {
+worker_task (void *args)
+{
void *context = zmq_init (1);
void *worker = zmq_socket (context, ZMQ_REQ);
@@ -60,7 +61,7 @@ int main (void)
int worker_nbr;
for (worker_nbr = 0; worker_nbr < NBR_WORKERS; worker_nbr++) {
pthread_t worker;
- pthread_create (&worker, NULL, worker_thread, NULL);
+ pthread_create (&worker, NULL, worker_task, NULL);
}
int task_nbr;
for (task_nbr = 0; task_nbr < NBR_WORKERS * 10; task_nbr++) {

0 comments on commit dd7677a

Please sign in to comment.