License header & style
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31016 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2009 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
|
||||||
|
* All rights reserved. Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef PORTLISTENER_H_
|
#ifndef PORTLISTENER_H_
|
||||||
#define PORTLISTENER_H_
|
#define PORTLISTENER_H_
|
||||||
|
|
||||||
@@ -6,7 +10,7 @@
|
|||||||
|
|
||||||
template <
|
template <
|
||||||
typename TYPE,
|
typename TYPE,
|
||||||
ssize_t MAX_MESSAGE_SIZE = 256,
|
ssize_t MAX_MESSAGE_SIZE = 256,
|
||||||
size_t MAX_MESSAGE_DEEP = 16,
|
size_t MAX_MESSAGE_DEEP = 16,
|
||||||
uint32 PRIORITY = B_URGENT_DISPLAY_PRIORITY>
|
uint32 PRIORITY = B_URGENT_DISPLAY_PRIORITY>
|
||||||
class PortListener {
|
class PortListener {
|
||||||
@@ -18,13 +22,12 @@ class PortListener {
|
|||||||
port_listener_func func;
|
port_listener_func func;
|
||||||
} fInformation;
|
} fInformation;
|
||||||
|
|
||||||
|
public:
|
||||||
public:
|
|
||||||
PortListener(const char* name, port_listener_func handler)
|
PortListener(const char* name, port_listener_func handler)
|
||||||
{
|
{
|
||||||
fInformation.func = handler;
|
fInformation.func = handler;
|
||||||
fInformation.port = &fPort;
|
fInformation.port = &fPort;
|
||||||
|
|
||||||
InitCheck();
|
InitCheck();
|
||||||
fPortName = strdup(name);
|
fPortName = strdup(name);
|
||||||
fThreadName = strdup(name);
|
fThreadName = strdup(name);
|
||||||
@@ -48,9 +51,9 @@ class PortListener {
|
|||||||
|
|
||||||
|
|
||||||
status_t TriggerCode(int32 code) {
|
status_t TriggerCode(int32 code) {
|
||||||
|
|
||||||
return write_port(fPort, code, NULL, 0);
|
return write_port(fPort, code, NULL, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -77,10 +80,10 @@ class PortListener {
|
|||||||
MAX_MESSAGE_DEEP, PRIORITY>::threadFunction, fThreadName, PRIORITY, &fInformation);
|
MAX_MESSAGE_DEEP, PRIORITY>::threadFunction, fThreadName, PRIORITY, &fInformation);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fThread < B_OK)
|
if (fThread < B_OK)
|
||||||
return fThread;
|
return fThread;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +100,7 @@ class PortListener {
|
|||||||
|
|
||||||
|
|
||||||
status_t Stop() {
|
status_t Stop() {
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
wait_for_thread(fThread, &status);
|
wait_for_thread(fThread, &status);
|
||||||
|
|||||||
Reference in New Issue
Block a user