daydaynatation
daydaynatation

Reputation: 550

How to create excutables with +RTS -N for concurrency in Haskell?

I would like to create a Windows executable.

My program uses the async library for concurrently downloading files from a website.

I remember in order to run concurrent programs, I need to provide the appropriate flags, both compile time and runtime.

For console program launching, i can simply do:

./myprogram.exe +RTS -N4 for example.

But what should I do if myprogram.exe is to be launched by clicking it?

Upvotes: 3

Views: 377

Answers (1)

Daniel Wagner
Daniel Wagner

Reputation: 152837

The user's guide says:

There are four ways to set RTS options:

  • on the command line between +RTS ... -RTS, when running the program (Setting RTS options on the command line)
  • at compile-time, using -with-rtsopts=⟨opts⟩ (Setting RTS options at compile time)
  • with the environment variable GHCRTS (Setting RTS options with the GHCRTS environment variable)
  • by overriding “hooks” in the runtime system (“Hooks” to change RTS behaviour)

The second bullet gets you where you want to go.

Additionally, many of the RTS options are programmatically controllable, in case you want to do some computation before choosing the value -- say, checking how many physical CPUs there are. For -N specifically, there is setNumCapabilities.

Upvotes: 4

Related Questions