#!/usr/bin/env perl

use FindBin;
use lib $FindBin::Bin;
use Run qw(ret run);
use strict;

my $tasks = run("tasks");
my $threads;

my $preset_threads = $ENV{'CHPL_THREADS'};
if ($preset_threads ne "") {
    warn "Explicit CHPL_THREADS value (\"$preset_threads\") is ignored.\n";
}

if ($tasks eq "fifo") {
    $threads = "pthreads";
} elsif ($tasks eq "massivethreads") {
    $threads = "none";
} elsif ($tasks eq "muxed") {
    $threads = "soft-threads";
} elsif ($tasks eq "qthreads") {
    $threads = "none";
} else {
    warn "Unexpected tasks value \"$tasks\".\n";
    $threads = "";
}

ret($threads);
print "$threads\n" unless caller;
