haiku/src/servers/app/AppServer.h
Axel Dörfler 3870c9f18f Improved quit mechanism (for the last time): if an application had open
windows that wouldn't quit on demand, the app_server would have gotten
the kShutdownServer message anyway already (as the last app was quit).
Since that one removed things like gDesktop/gBitmapManager, it liked
crashing.
Now, there is a semaphore that will be send to each app on quit. Only
when this semaphore can be acquired, the shutdown message will be sent.
Removed unused semaphores (decorator, active app).
Replaced fAppListLock with a BLocker (just calling acquire_sem() without
error checking is very unsafe in userland, and should never be done).

BTW the bug was triggered by broken menu code that only sometimes
really quit the window; it leaves a whole lot of zombies around - Stefano,
any quick idea? :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13384 a95241bf-73f2-0310-859d-f6bbb57e9c96
2005-07-01 10:09:11 +00:00

96 lines
1.9 KiB
C++

/*
* Copyright (c) 2001-2005, Haiku, Inc.
* Distributed under the terms of the MIT license.
*
* Author: DarkWyrm <bpmagic@columbus.rr.com>
*/
#ifndef _HAIKU_APP_SERVER_H_
#define _HAIKU_APP_SERVER_H_
#include <OS.h>
#include <Locker.h>
#include <List.h>
#include <Application.h>
#include <Window.h>
#include <String.h>
#include "ServerConfig.h"
class Layer;
class BMessage;
class ServerApp;
class DisplayDriver;
class CursorManager;
class BitmapManager;
class DecorManager;
class ColorSet;
namespace BPrivate {
class PortLink;
};
/*!
\class AppServer AppServer.h
\brief main manager object for the app_server
File for the main app_server thread. This particular thread monitors for
application start and quit messages. It also starts the housekeeping threads
and initializes most of the server's globals.
*/
class AppServer
#if TEST_MODE
: public BApplication
#endif
{
public:
AppServer(void);
~AppServer(void);
static int32 PollerThread(void *data);
static int32 PicassoThread(void *data);
thread_id Run(void);
void MainLoop(void);
void PostMessage(int32 code);
void DispatchMessage(int32 code, BPrivate::PortLink &link);
ServerApp* FindApp(const char *sig);
private:
friend void BroadcastToAllApps(const int32 &code);
void LaunchCursorThread();
void LaunchInputServer();
static int32 CursorThread(void *data);
port_id fMessagePort;
port_id fServerInputPort;
volatile bool fQuitting;
BLocker fAppListLock;
BList fAppList;
thread_id fPicassoThreadID;
thread_id fISThreadID;
thread_id fCursorThreadID;
sem_id fCursorSem;
area_id fCursorArea;
uint32 *fCursorAddr;
port_id fISASPort;
port_id fISPort;
sem_id fShutdownSemaphore;
int32 fShutdownCount;
DisplayDriver *fDriver;
};
extern BitmapManager *gBitmapManager;
extern ColorSet gGUIColorSet;
extern port_id gAppServerPort;
#endif /* _HAIKU_APP_SERVER_H_ */