* fix the build by moving a typedef to public scope, and avoid returning a value in the destructor
* some clean up git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31025 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -14,15 +14,9 @@ template <
|
|||||||
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 {
|
||||||
|
public:
|
||||||
typedef status_t (*port_listener_func)(TYPE*, int32, size_t);
|
typedef status_t (*port_listener_func)(TYPE*, int32, size_t);
|
||||||
|
|
||||||
struct PortListenerInfo {
|
|
||||||
port_id* port;
|
|
||||||
port_listener_func func;
|
|
||||||
} fInformation;
|
|
||||||
|
|
||||||
public:
|
|
||||||
PortListener(const char* name, port_listener_func handler)
|
PortListener(const char* name, port_listener_func handler)
|
||||||
{
|
{
|
||||||
fInformation.func = handler;
|
fInformation.func = handler;
|
||||||
@@ -35,8 +29,8 @@ class PortListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~PortListener() {
|
~PortListener()
|
||||||
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
close_port(fPort);
|
close_port(fPort);
|
||||||
@@ -45,20 +39,17 @@ class PortListener {
|
|||||||
|
|
||||||
delete fThreadName;
|
delete fThreadName;
|
||||||
delete fPortName;
|
delete fPortName;
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t TriggerCode(int32 code) {
|
status_t TriggerCode(int32 code)
|
||||||
|
{
|
||||||
return write_port(fPort, code, NULL, 0);
|
return write_port(fPort, code, NULL, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t InitCheck() {
|
status_t InitCheck()
|
||||||
|
{
|
||||||
// Create Port
|
// Create Port
|
||||||
fPort = find_port(fPortName);
|
fPort = find_port(fPortName);
|
||||||
if (fPort == B_NAME_NOT_FOUND) {
|
if (fPort == B_NAME_NOT_FOUND) {
|
||||||
@@ -88,8 +79,8 @@ class PortListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t Launch() {
|
status_t Launch()
|
||||||
|
{
|
||||||
status_t check = InitCheck();
|
status_t check = InitCheck();
|
||||||
|
|
||||||
if (check < B_OK)
|
if (check < B_OK)
|
||||||
@@ -99,16 +90,22 @@ class PortListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t Stop() {
|
status_t Stop()
|
||||||
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
|
|
||||||
wait_for_thread(fThread, &status);
|
wait_for_thread(fThread, &status);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct PortListenerInfo {
|
||||||
|
port_id* port;
|
||||||
|
port_listener_func func;
|
||||||
|
} fInformation;
|
||||||
|
|
||||||
port_id fPort;
|
port_id fPort;
|
||||||
thread_id fThread;
|
thread_id fThread;
|
||||||
char* fThreadName;
|
char* fThreadName;
|
||||||
@@ -152,7 +149,7 @@ class PortListener {
|
|||||||
|
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
if (ssizePort == B_BAD_PORT_ID) // the port dissapeared
|
if (ssizePort == B_BAD_PORT_ID) // the port disappeared
|
||||||
return ssizePort;
|
return ssizePort;
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
@@ -160,5 +157,5 @@ class PortListener {
|
|||||||
|
|
||||||
}; // PortListener
|
}; // PortListener
|
||||||
|
|
||||||
|
|
||||||
#endif // PORTLISTENER_H_
|
#endif // PORTLISTENER_H_
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user