registrar: Whitespace and style cleanup only.
Generally this code still looks horrible (both from a style and from a complexity point of view) and should eventually be reworked.
This commit is contained in:
@@ -43,9 +43,10 @@ namespace Mime {
|
||||
If \a replyee is non-NULL and construction succeeds, the MimeThreadObject
|
||||
assumes resposibility for its deletion.
|
||||
|
||||
Also, if \c non-NULL, \a replyee is expected to be a \c B_REG_MIME_UPDATE_MIME_INFO
|
||||
or a \c B_REG_MIME_CREATE_APP_META_MIME message with a \c true \c "synchronous"
|
||||
field detached from the registrar's mime manager looper (though this is not verified).
|
||||
Also, if \c non-NULL, \a replyee is expected to be a
|
||||
\c B_REG_MIME_UPDATE_MIME_INFO or a \c B_REG_MIME_CREATE_APP_META_MIME
|
||||
message with a \c true \c "synchronous" field detached from the registrar's
|
||||
mime manager looper (though this is not verified).
|
||||
The message will be replied to at the end of the thread's execution.
|
||||
*/
|
||||
MimeUpdateThread::MimeUpdateThread(const char *name, int32 priority,
|
||||
@@ -65,9 +66,9 @@ MimeUpdateThread::MimeUpdateThread(const char *name, int32 priority,
|
||||
|
||||
/*! \brief Destroys the MimeUpdateThread object.
|
||||
|
||||
If the object was properly initialized (i.e. InitCheck() returns \c B_OK) and
|
||||
the replyee message passed to the constructor was \c non-NULL, the replyee
|
||||
message is deleted.
|
||||
If the object was properly initialized (i.e. InitCheck() returns \c B_OK)
|
||||
and the replyee message passed to the constructor was \c non-NULL, the
|
||||
replyee message is deleted.
|
||||
*/
|
||||
MimeUpdateThread::~MimeUpdateThread()
|
||||
{
|
||||
@@ -122,13 +123,14 @@ MimeUpdateThread::ThreadFunction()
|
||||
// Notify the thread manager to make a cleanup run
|
||||
if (!err) {
|
||||
BMessage msg(B_REG_MIME_UPDATE_THREAD_FINISHED);
|
||||
status_t error = fManagerMessenger.SendMessage(&msg, (BHandler*)NULL, 500000);
|
||||
status_t error = fManagerMessenger.SendMessage(&msg, (BHandler*)NULL,
|
||||
500000);
|
||||
if (error)
|
||||
OUT("WARNING: ThreadManager::ThreadEntryFunction(): Termination notification "
|
||||
"failed with error 0x%" B_PRIx32 "\n", error);
|
||||
OUT("WARNING: ThreadManager::ThreadEntryFunction(): Termination"
|
||||
" notification failed with error 0x%" B_PRIx32 "\n", error);
|
||||
}
|
||||
DBG(OUT("(id: %ld) exiting mime update thread with result 0x%" B_PRIx32 "\n",
|
||||
find_thread(NULL), err));
|
||||
DBG(OUT("(id: %ld) exiting mime update thread with result 0x%" B_PRIx32
|
||||
"\n", find_thread(NULL), err));
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -152,8 +154,7 @@ MimeUpdateThread::DeviceSupportsAttributes(dev_t device)
|
||||
// See if an entry for this device already exists
|
||||
std::list< std::pair<dev_t,bool> >::iterator i;
|
||||
for (i = fAttributeSupportList.begin();
|
||||
i != fAttributeSupportList.end();
|
||||
i++)
|
||||
i != fAttributeSupportList.end(); i++)
|
||||
{
|
||||
if (i->first == device)
|
||||
return i->second;
|
||||
@@ -180,8 +181,8 @@ MimeUpdateThread::DeviceSupportsAttributes(dev_t device)
|
||||
}
|
||||
|
||||
// UpdateEntry
|
||||
/*! \brief Updates the given entry and then recursively updates all the entry's child
|
||||
entries if the entry is a directory and \c fRecursive is true.
|
||||
/*! \brief Updates the given entry and then recursively updates all the entry's
|
||||
child entries if the entry is a directory and \c fRecursive is true.
|
||||
*/
|
||||
status_t
|
||||
MimeUpdateThread::UpdateEntry(const entry_ref *ref)
|
||||
@@ -222,11 +223,10 @@ MimeUpdateThread::UpdateEntry(const entry_ref *ref)
|
||||
// If we've come to the end of the directory listing,
|
||||
// it's not an error.
|
||||
if (err == B_ENTRY_NOT_FOUND)
|
||||
err = B_OK;
|
||||
err = B_OK;
|
||||
break;
|
||||
} else {
|
||||
} else
|
||||
err = UpdateEntry(&childRef);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
|
||||
/*! \class RegistrarThread
|
||||
\brief Base thread class for threads spawned and managed by the registrar
|
||||
|
||||
*/
|
||||
|
||||
// constructor
|
||||
@@ -29,13 +28,15 @@
|
||||
\param managerMessenger A BMessenger to the thread manager to which this
|
||||
thread does or will belong.
|
||||
*/
|
||||
RegistrarThread::RegistrarThread(const char *name, int32 priority, BMessenger managerMessenger)
|
||||
: fManagerMessenger(managerMessenger)
|
||||
, fShouldExit(false)
|
||||
, fIsFinished(false)
|
||||
, fStatus(B_NO_INIT)
|
||||
, fId(-1)
|
||||
, fPriority(priority)
|
||||
RegistrarThread::RegistrarThread(const char *name, int32 priority,
|
||||
BMessenger managerMessenger)
|
||||
:
|
||||
fManagerMessenger(managerMessenger),
|
||||
fShouldExit(false),
|
||||
fIsFinished(false),
|
||||
fStatus(B_NO_INIT),
|
||||
fId(-1),
|
||||
fPriority(priority)
|
||||
{
|
||||
fName[0] = 0;
|
||||
status_t err = name && fManagerMessenger.IsValid() ? B_OK : B_BAD_VALUE;
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
|
||||
class RegistrarThread {
|
||||
public:
|
||||
RegistrarThread(const char *name, int32 priority, BMessenger managerMessenger);
|
||||
RegistrarThread(const char *name, int32 priority,
|
||||
BMessenger managerMessenger);
|
||||
virtual ~RegistrarThread();
|
||||
|
||||
virtual status_t InitCheck();
|
||||
@@ -33,7 +34,8 @@ protected:
|
||||
|
||||
BMessenger fManagerMessenger;
|
||||
bool fShouldExit; // Initially false, may be set to true by AskToExit()
|
||||
bool fIsFinished; // Initially false, set to true by the thread itself upon completion
|
||||
bool fIsFinished; // Initially false, set to true by the thread itself
|
||||
// upon completion
|
||||
private:
|
||||
static int32 EntryFunction(void *data);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ using namespace BPrivate;
|
||||
|
||||
/*!
|
||||
\class RegistrarThreadManager
|
||||
\brief RegistrarThreadManager is the master of all threads spawned by the registrar
|
||||
|
||||
\brief RegistrarThreadManager is the master of all threads spawned by the
|
||||
registrar
|
||||
*/
|
||||
|
||||
//! Creates a new RegistrarThreadManager object
|
||||
@@ -35,8 +35,8 @@ RegistrarThreadManager::RegistrarThreadManager()
|
||||
}
|
||||
|
||||
// destructor
|
||||
/*! \brief Destroys the RegistrarThreadManager object, killing and deleting any still
|
||||
running threads.
|
||||
/*! \brief Destroys the RegistrarThreadManager object, killing and deleting any
|
||||
still running threads.
|
||||
*/
|
||||
RegistrarThreadManager::~RegistrarThreadManager()
|
||||
{
|
||||
@@ -44,9 +44,11 @@ RegistrarThreadManager::~RegistrarThreadManager()
|
||||
}
|
||||
|
||||
// MessageReceived
|
||||
/*! \brief Handles \c B_REG_MIME_UPDATE_THREAD_FINISHED messages, passing on all others.
|
||||
/*! \brief Handles \c B_REG_MIME_UPDATE_THREAD_FINISHED messages, passing on all
|
||||
others.
|
||||
|
||||
Each \c B_REG_MIME_UPDATE_THREAD_FINISHED message triggers a call to CleanupThreads().
|
||||
Each \c B_REG_MIME_UPDATE_THREAD_FINISHED message triggers a call to
|
||||
CleanupThreads().
|
||||
*/
|
||||
void
|
||||
RegistrarThreadManager::MessageReceived(BMessage* message)
|
||||
@@ -72,14 +74,15 @@ RegistrarThreadManager::MessageReceived(BMessage* message)
|
||||
|
||||
\param thread Pointer to a newly allocated \c RegistrarThread object.
|
||||
|
||||
If the result of the function is \c B_OK, the \c RegistrarThreadManager object
|
||||
assumes ownership of \a thread; if the result is an error code, it
|
||||
If the result of the function is \c B_OK, the \c RegistrarThreadManager
|
||||
object assumes ownership of \a thread; if the result is an error code, it
|
||||
does not.
|
||||
|
||||
\return
|
||||
- \c B_OK: success
|
||||
- \c B_NO_MORE_THREADS: the number of concurrently allowed threads (defined by
|
||||
RegistrarThreadManager::kThreadLimit) has already been reached
|
||||
- \c B_NO_MORE_THREADS: the number of concurrently allowed threads (defined
|
||||
by RegistrarThreadManager::kThreadLimit) has
|
||||
already been reached
|
||||
- \c B_BAD_THREAD_STATE: the thread has already been launched
|
||||
- other error code: failure
|
||||
*/
|
||||
@@ -110,8 +113,8 @@ RegistrarThreadManager::LaunchThread(RegistrarThread *thread)
|
||||
}
|
||||
}
|
||||
if (!err)
|
||||
DBG(OUT("RegistrarThreadManager::LaunchThread(): launched new '%s' thread, "
|
||||
"id %ld\n", thread->Name(), thread->Id()));
|
||||
DBG(OUT("RegistrarThreadManager::LaunchThread(): launched new '%s'"
|
||||
" thread, id %ld\n", thread->Name(), thread->Id()));
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -128,15 +131,16 @@ RegistrarThreadManager::CleanupThreads()
|
||||
for (i = fThreads.begin(); i != fThreads.end(); ) {
|
||||
if (*i) {
|
||||
if ((*i)->IsFinished()) {
|
||||
DBG(OUT("RegistrarThreadManager::CleanupThreads(): Cleaning up thread %ld\n",
|
||||
(*i)->Id()));
|
||||
DBG(OUT("RegistrarThreadManager::CleanupThreads(): Cleaning up"
|
||||
" thread %ld\n", (*i)->Id()));
|
||||
RemoveThread(i);
|
||||
// adjusts i
|
||||
} else
|
||||
++i;
|
||||
} else {
|
||||
OUT("WARNING: RegistrarThreadManager::CleanupThreads(): NULL mime_update_thread_shared_data "
|
||||
"pointer found in and removed from RegistrarThreadManager::fThreads list\n");
|
||||
OUT("WARNING: RegistrarThreadManager::CleanupThreads(): NULL"
|
||||
" mime_update_thread_shared_data pointer found in and removed"
|
||||
" from RegistrarThreadManager::fThreads list\n");
|
||||
i = fThreads.erase(i);
|
||||
}
|
||||
}
|
||||
@@ -157,19 +161,20 @@ RegistrarThreadManager::ShutdownThreads()
|
||||
for (i = fThreads.begin(); i != fThreads.end(); ) {
|
||||
if (*i) {
|
||||
if ((*i)->IsFinished()) {
|
||||
DBG(OUT("RegistrarThreadManager::ShutdownThreads(): Cleaning up thread %ld\n",
|
||||
(*i)->Id()));
|
||||
DBG(OUT("RegistrarThreadManager::ShutdownThreads(): Cleaning up"
|
||||
" thread %ld\n", (*i)->Id()));
|
||||
RemoveThread(i);
|
||||
// adjusts i
|
||||
} else {
|
||||
DBG(OUT("RegistrarThreadManager::ShutdownThreads(): Shutting down thread %ld\n",
|
||||
(*i)->Id()));
|
||||
DBG(OUT("RegistrarThreadManager::ShutdownThreads(): Shutting"
|
||||
" down thread %ld\n", (*i)->Id()));
|
||||
(*i)->AskToExit();
|
||||
++i;
|
||||
}
|
||||
} else {
|
||||
OUT("WARNING: RegistrarThreadManager::ShutdownThreads(): NULL mime_update_thread_shared_data "
|
||||
"pointer found in and removed from RegistrarThreadManager::fThreads list\n");
|
||||
OUT("WARNING: RegistrarThreadManager::ShutdownThreads(): NULL"
|
||||
" mime_update_thread_shared_data pointer found in and removed"
|
||||
" from RegistrarThreadManager::fThreads list\n");
|
||||
i = fThreads.erase(i);
|
||||
}
|
||||
}
|
||||
@@ -195,21 +200,22 @@ RegistrarThreadManager::KillThreads()
|
||||
for (i = fThreads.begin(); i != fThreads.end(); ) {
|
||||
if (*i) {
|
||||
if (!(*i)->IsFinished()) {
|
||||
DBG(OUT("RegistrarThreadManager::KillThreads(): Killing thread %ld\n",
|
||||
(*i)->Id()));
|
||||
DBG(OUT("RegistrarThreadManager::KillThreads(): Killing thread"
|
||||
" %ld\n", (*i)->Id()));
|
||||
status_t err = kill_thread((*i)->Id());
|
||||
if (err)
|
||||
OUT("WARNING: RegistrarThreadManager::KillThreads(): kill_thread(%"
|
||||
B_PRId32 ") failed with error code 0x%" B_PRIx32 "\n",
|
||||
(*i)->Id(), err);
|
||||
OUT("WARNING: RegistrarThreadManager::KillThreads():"
|
||||
" kill_thread(%" B_PRId32 ") failed with error code"
|
||||
" 0x%" B_PRIx32 "\n", (*i)->Id(), err);
|
||||
}
|
||||
DBG(OUT("RegistrarThreadManager::KillThreads(): Cleaning up thread %ld\n",
|
||||
(*i)->Id()));
|
||||
DBG(OUT("RegistrarThreadManager::KillThreads(): Cleaning up thread"
|
||||
" %ld\n", (*i)->Id()));
|
||||
RemoveThread(i);
|
||||
// adjusts i
|
||||
} else {
|
||||
OUT("WARNING: RegistrarThreadManager::KillThreads(): NULL mime_update_thread_shared_data "
|
||||
"pointer found in and removed from RegistrarThreadManager::fThreads list\n");
|
||||
OUT("WARNING: RegistrarThreadManager::KillThreads(): NULL"
|
||||
" mime_update_thread_shared_data pointer found in and removed"
|
||||
" from RegistrarThreadManager::fThreads list\n");
|
||||
i = fThreads.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
static const int kThreadLimit = 12;
|
||||
private:
|
||||
|
||||
std::list<RegistrarThread*>::iterator& RemoveThread(std::list<RegistrarThread*>::iterator &i);
|
||||
std::list<RegistrarThread*>::iterator&
|
||||
RemoveThread(std::list<RegistrarThread*>::iterator &i);
|
||||
|
||||
std::list<RegistrarThread*> fThreads;
|
||||
int32 fThreadCount;
|
||||
|
||||
Reference in New Issue
Block a user