Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
gc.config: updated comments, allow disabling command line processing,…
Browse files Browse the repository at this point in the history
… change environment var to DRT_GCOPT
  • Loading branch information
rainers committed Oct 8, 2014
1 parent f400e66 commit f818017
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/gc/config.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@

module gc.config;

// to add the possiblity to configure the GC from the outside, add gc.config
// with one of these versions to the executable build command line, e.g.
// dmd -version=initGCFromEnvironment main.c /path/to/druntime/src/gc/config.d
// The default way to confige the GC is by passing command line argument --DRT-gcopt to
// the executable, use --DRT-gcopt=help for a list of available options.
//
// Configuration can be disabled by building this module with version noinitGCFromCommandline
// and linking it with your executable:
// dmd -version=noinitGCFromCommandline main.d /path/to/druntime/src/gc/config.d
//
// If you want to allow configuration by an environment variable DRT_GCOPT aswell, compile
// gc.config with version initGCFromEnvironment:
// dmd -version=initGCFromEnvironment main.d /path/to/druntime/src/gc/config.d

//version = initGCFromEnvironment; // read settings from environment variable D_GC
//version = initGCFromEnvironment; // read settings from environment variable DRT_GCOPT
version(noinitGCFromCommandline) {} else
version = initGCFromCommandLine; // read settings from command line argument "--DRT-gcopt=options"

version(initGCFromEnvironment)
Expand All @@ -36,14 +44,14 @@ struct Config

size_t initReserve; // initial reserve (MB)
size_t minPoolSize = 1; // initial and minimum pool size (MB)
size_t maxPoolSize = 32; // maximum pool size (MB)
size_t maxPoolSize = 64; // maximum pool size (MB)
size_t incPoolSize = 3; // pool size increment (MB)

bool initialize(...) // avoid inlining
{
version(initGCFromEnvironment)
{
auto p = getenv("D_GC");
auto p = getenv("DRT_GCOPT");
if (p)
if (!parseOptions(p[0 .. strlen(p)]))
return false;
Expand Down Expand Up @@ -72,7 +80,7 @@ struct Config
initReserve=N - initial memory to reserve (MB), default 0
minPoolSize=N - initial and minimum pool size (MB), default 1
maxPoolSize=N - maximum pool size (MB), default 32
maxPoolSize=N - maximum pool size (MB), default 64
incPoolSize=N - pool size increment (MB), defaut 3
";
}
Expand Down

0 comments on commit f818017

Please sign in to comment.