File: ApplicationPool.cpp

package info (click to toggle)
passenger 2.2.11debian-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,576 kB
  • ctags: 28,138
  • sloc: cpp: 66,323; ruby: 9,646; ansic: 2,425; python: 141; sh: 56; makefile: 29
file content (52 lines) | stat: -rw-r--r-- 1,068 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//#define USE_SERVER

#include <iostream>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#ifdef USE_SERVER
	#include "ApplicationPoolServer.h"
#else
	#include "StandardApplicationPool.h"
#endif
#include "Utils.h"
#include "Logging.h"

using namespace std;
using namespace boost;
using namespace Passenger;

#define TRANSACTIONS 20000
#define CONCURRENCY 24

ApplicationPoolPtr pool;

static void
threadMain(unsigned int times) {
	for (unsigned int i = 0; i < times; i++) {
		Application::SessionPtr session(pool->get("test/stub/minimal-railsapp"));
		for (int x = 0; x < 200000; x++) {
			// Do nothing.
		}
	}
}

int
main() {
	thread_group tg;
	#ifdef USE_SERVER
		ApplicationPoolServer server("ext/apache2/ApplicationPoolServerExecutable",
			"bin/passenger-spawn-server");
		pool = server.connect();
	#else
		pool = ptr(new StandardApplicationPool("bin/passenger-spawn-server"));
	#endif
	pool->setMax(6);
	
	for (int i = 0; i < CONCURRENCY; i++) {
		tg.create_thread(boost::bind(&threadMain, TRANSACTIONS / CONCURRENCY));
	}
	
	tg.join_all();
	return 0;
}