- NO FUNCTIONAL CODE CHANGES!!!!
- changed code formating from tabs to spaces and others - used astyle with this option: --style=ansi --indent=spaces=2 -M --pad-oper --unpad-paren --pad-header --align-pointer=name --lineend=linux
This commit is contained in:
parent
b100e9d32a
commit
1c8e43e6d6
76 changed files with 5691 additions and 5492 deletions
|
@ -15,13 +15,13 @@ static const char *ECHO_SERVER_NAME = "org.freedesktop.DBus.Examples.Echo";
|
|||
static const char *ECHO_SERVER_PATH = "/org/freedesktop/DBus/Examples/Echo";
|
||||
|
||||
EchoClient::EchoClient(DBus::Connection &connection, const char *path, const char *name)
|
||||
: DBus::ObjectProxy(connection, path, name)
|
||||
: DBus::ObjectProxy(connection, path, name)
|
||||
{
|
||||
}
|
||||
|
||||
void EchoClient::Echoed(const DBus::Variant &value)
|
||||
{
|
||||
cout << "!";
|
||||
cout << "!";
|
||||
}
|
||||
|
||||
static const size_t THREADS = 3;
|
||||
|
@ -37,96 +37,96 @@ DBus::DefaultTimeout *timeout;
|
|||
|
||||
void *greeter_thread(void *arg)
|
||||
{
|
||||
char idstr[16];
|
||||
size_t i = (size_t) arg;
|
||||
char idstr[16];
|
||||
size_t i = (size_t) arg;
|
||||
|
||||
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
|
||||
snprintf(idstr, sizeof(idstr), "%lu", pthread_self());
|
||||
|
||||
thread_pipe_list[i]->write (idstr, strlen (idstr) + 1);
|
||||
thread_pipe_list[i]->write(idstr, strlen(idstr) + 1);
|
||||
|
||||
cout << idstr << " done (" << i << ")" << endl;
|
||||
cout << idstr << " done (" << i << ")" << endl;
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void niam(int sig)
|
||||
{
|
||||
spin = false;
|
||||
spin = false;
|
||||
|
||||
dispatcher.leave();
|
||||
dispatcher.leave();
|
||||
}
|
||||
|
||||
void handler1 (const void *data, void *buffer, unsigned int nbyte)
|
||||
void handler1(const void *data, void *buffer, unsigned int nbyte)
|
||||
{
|
||||
char *str = (char*) buffer;
|
||||
cout << "buffer1: " << str << ", size: " << nbyte << endl;
|
||||
for (int i = 0; i < 30 && spin; ++i)
|
||||
{
|
||||
cout << "call1: " << g_client->Hello (str) << endl;
|
||||
}
|
||||
char *str = (char *) buffer;
|
||||
cout << "buffer1: " << str << ", size: " << nbyte << endl;
|
||||
for (int i = 0; i < 30 && spin; ++i)
|
||||
{
|
||||
cout << "call1: " << g_client->Hello(str) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void handler2 (const void *data, void *buffer, unsigned int nbyte)
|
||||
void handler2(const void *data, void *buffer, unsigned int nbyte)
|
||||
{
|
||||
char *str = (char*) buffer;
|
||||
cout << "buffer2: " << str << ", size: " << nbyte <<endl;
|
||||
for (int i = 0; i < 30 && spin; ++i)
|
||||
{
|
||||
cout << "call2: " << g_client->Hello (str) << endl;
|
||||
}
|
||||
char *str = (char *) buffer;
|
||||
cout << "buffer2: " << str << ", size: " << nbyte << endl;
|
||||
for (int i = 0; i < 30 && spin; ++i)
|
||||
{
|
||||
cout << "call2: " << g_client->Hello(str) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void handler3 (const void *data, void *buffer, unsigned int nbyte)
|
||||
void handler3(const void *data, void *buffer, unsigned int nbyte)
|
||||
{
|
||||
char *str = (char*) buffer;
|
||||
cout << "buffer3: " << str << ", size: " << nbyte <<endl;
|
||||
for (int i = 0; i < 30 && spin; ++i)
|
||||
{
|
||||
cout << "call3: " << g_client->Hello (str) << endl;
|
||||
}
|
||||
char *str = (char *) buffer;
|
||||
cout << "buffer3: " << str << ", size: " << nbyte << endl;
|
||||
for (int i = 0; i < 30 && spin; ++i)
|
||||
{
|
||||
cout << "call3: " << g_client->Hello(str) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
size_t i;
|
||||
size_t i;
|
||||
|
||||
signal(SIGTERM, niam);
|
||||
signal(SIGINT, niam);
|
||||
signal(SIGTERM, niam);
|
||||
signal(SIGINT, niam);
|
||||
|
||||
DBus::_init_threading();
|
||||
DBus::_init_threading();
|
||||
|
||||
DBus::default_dispatcher = &dispatcher;
|
||||
|
||||
// increase DBus-C++ frequency
|
||||
new DBus::DefaultTimeout(100, false, &dispatcher);
|
||||
|
||||
DBus::Connection conn = DBus::Connection::SessionBus();
|
||||
DBus::Connection conn = DBus::Connection::SessionBus();
|
||||
|
||||
EchoClient client (conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
|
||||
g_client = &client;
|
||||
EchoClient client(conn, ECHO_SERVER_PATH, ECHO_SERVER_NAME);
|
||||
g_client = &client;
|
||||
|
||||
pthread_t threads[THREADS];
|
||||
pthread_t threads[THREADS];
|
||||
|
||||
thread_pipe_list[0] = dispatcher.add_pipe (handler1, NULL);
|
||||
thread_pipe_list[1] = dispatcher.add_pipe (handler2, NULL);
|
||||
thread_pipe_list[2] = dispatcher.add_pipe (handler3, NULL);
|
||||
for (i = 0; i < THREADS; ++i)
|
||||
{
|
||||
pthread_create(threads+i, NULL, greeter_thread, (void*) i);
|
||||
}
|
||||
|
||||
dispatcher.enter();
|
||||
thread_pipe_list[0] = dispatcher.add_pipe(handler1, NULL);
|
||||
thread_pipe_list[1] = dispatcher.add_pipe(handler2, NULL);
|
||||
thread_pipe_list[2] = dispatcher.add_pipe(handler3, NULL);
|
||||
for (i = 0; i < THREADS; ++i)
|
||||
{
|
||||
pthread_create(threads + i, NULL, greeter_thread, (void *) i);
|
||||
}
|
||||
|
||||
cout << "terminating" << endl;
|
||||
dispatcher.enter();
|
||||
|
||||
for (i = 0; i < THREADS; ++i)
|
||||
{
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
cout << "terminating" << endl;
|
||||
|
||||
dispatcher.del_pipe (thread_pipe_list[0]);
|
||||
dispatcher.del_pipe (thread_pipe_list[1]);
|
||||
dispatcher.del_pipe (thread_pipe_list[2]);
|
||||
for (i = 0; i < THREADS; ++i)
|
||||
{
|
||||
pthread_join(threads[i], NULL);
|
||||
}
|
||||
|
||||
return 0;
|
||||
dispatcher.del_pipe(thread_pipe_list[0]);
|
||||
dispatcher.del_pipe(thread_pipe_list[1]);
|
||||
dispatcher.del_pipe(thread_pipe_list[2]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue