16 BTestHandler::MessageReceived(BMessage
*message
)
19 BMessage
*clone
= new BMessage(*message
);
21 fQueue
.AddMessage(clone
);
36 static status_t sInitError
;
40 BTestApp::BTestApp(const char *signature
)
41 : BApplication(signature
, &sInitError
),
45 if (sInitError
!= B_OK
) {
46 fprintf(stderr
, "BTestApp::BTestApp(): Failed to create BApplication: "
47 "%s\n", strerror(sInitError
));
59 int32 count
= fHandlers
.CountItems();
60 for (int32 i
= count
- 1; i
>= 0; i
--)
61 DeleteTestHandler(TestHandlerAt(i
));
69 status_t error
= B_OK
;
70 fAppThread
= spawn_thread(&_AppThreadStart
, "query app",
71 B_NORMAL_PRIORITY
, this);
75 error
= resume_thread(fAppThread
);
77 kill_thread(fAppThread
);
89 PostMessage(B_QUIT_REQUESTED
, this);
91 wait_for_thread(fAppThread
, &result
);
97 BTestApp::ReadyToRun()
104 BTestApp::CreateTestHandler()
106 BTestHandler
*handler
= new BTestHandler
;
109 fHandlers
.AddItem(handler
);
117 BTestApp::DeleteTestHandler(BTestHandler
*handler
)
121 result
= fHandlers
.RemoveItem(handler
);
123 RemoveHandler(handler
);
135 // The returned handler must never passed to DeleteTestHandler() by the
137 return *TestHandlerAt(0);
143 BTestApp::TestHandlerAt(int32 index
)
145 BAutolock
_lock(this);
146 return (BTestHandler
*)fHandlers
.ItemAt(index
);
152 BTestApp::_AppThreadStart(void *data
)
154 if (BTestApp
*app
= (BTestApp
*)data
) {