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,17 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2004-2010, Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
#ifndef _ADD_ON_MONITOR_H
|
#ifndef _ADD_ON_MONITOR_H
|
||||||
#define _ADD_ON_MONITOR_H
|
#define _ADD_ON_MONITOR_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <Looper.h>
|
#include <Looper.h>
|
||||||
#include <MessageRunner.h>
|
#include <MessageRunner.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
namespace Storage {
|
namespace Storage {
|
||||||
|
|
||||||
|
|
||||||
class AddOnMonitorHandler;
|
class AddOnMonitorHandler;
|
||||||
|
|
||||||
|
|
||||||
class AddOnMonitor : public BLooper {
|
class AddOnMonitor : public BLooper {
|
||||||
private:
|
private:
|
||||||
typedef BLooper inherited;
|
typedef BLooper inherited;
|
||||||
@@ -23,13 +32,15 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
status_t fInitCheck;
|
status_t fInitCheck;
|
||||||
BMessage * fPulseMessage;
|
|
||||||
BMessageRunner* fPulseRunner;
|
BMessageRunner* fPulseRunner;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}; // namespace Storage
|
}; // namespace Storage
|
||||||
}; // namespace BPrivate
|
}; // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
using namespace BPrivate::Storage;
|
using namespace BPrivate::Storage;
|
||||||
|
|
||||||
|
|
||||||
#endif // _ADD_ON_MONITOR_H
|
#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 "AddOnMonitor.h"
|
||||||
#include "AddOnMonitorHandler.h"
|
#include "AddOnMonitorHandler.h"
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
@@ -5,50 +14,50 @@
|
|||||||
#include <Messenger.h>
|
#include <Messenger.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
AddOnMonitor::AddOnMonitor(AddOnMonitorHandler* handler)
|
AddOnMonitor::AddOnMonitor(AddOnMonitorHandler* handler)
|
||||||
: BLooper("AddOnMonitor")
|
:
|
||||||
|
BLooper("AddOnMonitor"),
|
||||||
|
fInitCheck(B_NO_INIT)
|
||||||
{
|
{
|
||||||
fInitCheck = B_NO_INIT;
|
|
||||||
AddHandler(handler);
|
AddHandler(handler);
|
||||||
SetPreferredHandler(handler);
|
SetPreferredHandler(handler);
|
||||||
|
|
||||||
status_t status;
|
status_t status;
|
||||||
BMessenger messenger(handler, this, &status);
|
BMessenger messenger(handler, this, &status);
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
fInitCheck = status;
|
fInitCheck = status;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!messenger.IsValid()) {
|
|
||||||
fInitCheck = B_ERROR;
|
BMessage pulseMessage(B_PULSE);
|
||||||
return;
|
fPulseRunner = new BMessageRunner(messenger, &pulseMessage, 1000000);
|
||||||
}
|
|
||||||
fPulseMessage = new BMessage(B_PULSE);
|
|
||||||
fPulseRunner = new BMessageRunner(messenger, fPulseMessage, 1000000);
|
|
||||||
status = fPulseRunner->InitCheck();
|
status = fPulseRunner->InitCheck();
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
fInitCheck = status;
|
fInitCheck = status;
|
||||||
fprintf(stderr, "AddOnMonitor() : bad status returned by fPulseRunner->InitCheck()\n");
|
fprintf(stderr, "AddOnMonitor() : bad status returned by "
|
||||||
|
"fPulseRunner->InitCheck()\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_id id = Run();
|
thread_id id = Run();
|
||||||
if (id < 0) {
|
if (id < 0) {
|
||||||
fInitCheck = (status_t)id;
|
fInitCheck = (status_t)id;
|
||||||
fprintf(stderr, "AddOnMonitor() : bad id returned by Run()\n");
|
fprintf(stderr, "AddOnMonitor() : bad id returned by Run()\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fInitCheck = B_OK;
|
fInitCheck = B_OK;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virtual */
|
|
||||||
AddOnMonitor::~AddOnMonitor()
|
AddOnMonitor::~AddOnMonitor()
|
||||||
{
|
{
|
||||||
delete fPulseMessage;
|
|
||||||
delete fPulseRunner;
|
delete fPulseRunner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* virtual */ status_t
|
status_t
|
||||||
AddOnMonitor::InitCheck()
|
AddOnMonitor::InitCheck()
|
||||||
{
|
{
|
||||||
return fInitCheck;
|
return fInitCheck;
|
||||||
|
|||||||
Reference in New Issue
Block a user