Cleanup: No need to check the BMessenger status twice. No need to
keep the BMessageRunner message around. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38234 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,35 +1,46 @@
|
||||
/*
|
||||
* Copyright 2004-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _ADD_ON_MONITOR_H
|
||||
#define _ADD_ON_MONITOR_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <list>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
|
||||
#include <Looper.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
namespace Storage {
|
||||
|
||||
|
||||
class AddOnMonitorHandler;
|
||||
|
||||
|
||||
class AddOnMonitor : public BLooper {
|
||||
private:
|
||||
typedef BLooper inherited;
|
||||
typedef BLooper inherited;
|
||||
public:
|
||||
AddOnMonitor(AddOnMonitorHandler * handler);
|
||||
virtual ~AddOnMonitor();
|
||||
AddOnMonitor(AddOnMonitorHandler* handler);
|
||||
virtual ~AddOnMonitor();
|
||||
|
||||
virtual status_t InitCheck();
|
||||
virtual status_t InitCheck();
|
||||
|
||||
private:
|
||||
status_t fInitCheck;
|
||||
BMessage * fPulseMessage;
|
||||
BMessageRunner * fPulseRunner;
|
||||
status_t fInitCheck;
|
||||
BMessageRunner* fPulseRunner;
|
||||
};
|
||||
|
||||
|
||||
}; // namespace Storage
|
||||
}; // namespace BPrivate
|
||||
|
||||
|
||||
using namespace BPrivate::Storage;
|
||||
|
||||
|
||||
#endif // _ADD_ON_MONITOR_H
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* Copyright 2004-2010, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Andrew Bachmann
|
||||
*/
|
||||
|
||||
|
||||
#include "AddOnMonitor.h"
|
||||
#include "AddOnMonitorHandler.h"
|
||||
#include <Message.h>
|
||||
@@ -5,50 +14,50 @@
|
||||
#include <Messenger.h>
|
||||
#include <stdio.h>
|
||||
|
||||
AddOnMonitor::AddOnMonitor(AddOnMonitorHandler * handler)
|
||||
: BLooper("AddOnMonitor")
|
||||
|
||||
AddOnMonitor::AddOnMonitor(AddOnMonitorHandler* handler)
|
||||
:
|
||||
BLooper("AddOnMonitor"),
|
||||
fInitCheck(B_NO_INIT)
|
||||
{
|
||||
fInitCheck = B_NO_INIT;
|
||||
AddHandler(handler);
|
||||
SetPreferredHandler(handler);
|
||||
|
||||
status_t status;
|
||||
BMessenger messenger(handler, this, &status);
|
||||
if (status != B_OK) {
|
||||
fInitCheck = status;
|
||||
return;
|
||||
}
|
||||
if (!messenger.IsValid()) {
|
||||
fInitCheck = B_ERROR;
|
||||
return;
|
||||
}
|
||||
fPulseMessage = new BMessage(B_PULSE);
|
||||
fPulseRunner = new BMessageRunner(messenger, fPulseMessage, 1000000);
|
||||
|
||||
BMessage pulseMessage(B_PULSE);
|
||||
fPulseRunner = new BMessageRunner(messenger, &pulseMessage, 1000000);
|
||||
status = fPulseRunner->InitCheck();
|
||||
if (status != B_OK) {
|
||||
fInitCheck = status;
|
||||
fprintf(stderr, "AddOnMonitor() : bad status returned by fPulseRunner->InitCheck()\n");
|
||||
fprintf(stderr, "AddOnMonitor() : bad status returned by "
|
||||
"fPulseRunner->InitCheck()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
thread_id id = Run();
|
||||
if (id < 0) {
|
||||
fInitCheck = (status_t)id;
|
||||
fprintf(stderr, "AddOnMonitor() : bad id returned by Run()\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fInitCheck = B_OK;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* virtual */
|
||||
AddOnMonitor::~AddOnMonitor()
|
||||
{
|
||||
delete fPulseMessage;
|
||||
delete fPulseRunner;
|
||||
}
|
||||
|
||||
|
||||
/* virtual */ status_t
|
||||
status_t
|
||||
AddOnMonitor::InitCheck()
|
||||
{
|
||||
return fInitCheck;
|
||||
|
||||
Reference in New Issue
Block a user