* 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:
Jérôme Duval 2009-06-13 10:42:11 +00:00
parent bcc2ed0722
commit 581708b997
2 changed files with 38 additions and 41 deletions

View File

@ -14,15 +14,9 @@ template <
size_t MAX_MESSAGE_DEEP = 16,
uint32 PRIORITY = B_URGENT_DISPLAY_PRIORITY>
class PortListener {
public:
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)
{
fInformation.func = handler;
@ -35,8 +29,8 @@ class PortListener {
}
~PortListener() {
~PortListener()
{
status_t status;
close_port(fPort);
@ -45,20 +39,17 @@ class PortListener {
delete fThreadName;
delete fPortName;
return status;
}
status_t TriggerCode(int32 code) {
status_t TriggerCode(int32 code)
{
return write_port(fPort, code, NULL, 0);
}
status_t InitCheck() {
status_t InitCheck()
{
// Create Port
fPort = find_port(fPortName);
if (fPort == B_NAME_NOT_FOUND) {
@ -88,8 +79,8 @@ class PortListener {
}
status_t Launch() {
status_t Launch()
{
status_t check = InitCheck();
if (check < B_OK)
@ -99,16 +90,22 @@ class PortListener {
}
status_t Stop() {
status_t Stop()
{
status_t status;
wait_for_thread(fThread, &status);
return status;
}
private:
struct PortListenerInfo {
port_id* port;
port_listener_func func;
} fInformation;
port_id fPort;
thread_id fThread;
char* fThreadName;
@ -152,7 +149,7 @@ class PortListener {
free(buffer);
if (ssizePort == B_BAD_PORT_ID) // the port dissapeared
if (ssizePort == B_BAD_PORT_ID) // the port disappeared
return ssizePort;
return status;
@ -160,5 +157,5 @@ class PortListener {
}; // PortListener
#endif // PORTLISTENER_H_