Fix bug 5842.

The bug is caused by rehash producing an AA with a zero-size hashtable
when called on an empty but non-null AA.
reduce repetition and sleep time for rwmutex tests
rewrite semaphore tests to reduce test time

- use core.atomic to reduce locking
reduce condition timeout wait
When AA is empty, rehash should revert it to original state.
Need to call GC.free on old table in AA rehash.
Merge pull request #576 from quickfur/issue5842

Fix bug 5842.
Add forward range capability to AA .byKey and .byValue.
Merge pull request #582 from quickfur/aa_fwdrange

Add forward range capability to AA .byKey and .byValue
Merge pull request #580 from dawgfoto/reduceTestTime

reduce test time
Thread.sleep for windows: for non-zero timeout, sleep at least 1ms
rewrite rwmutext unittest

- use semaphores to control thread progress
- test different reader/writer scenarios and
  policies
range.empty should not be callable with parenthesis
Make AA.byKey and byValue non-property functions
Make AA.rehash non-property function
Make AA.dup non-property function
Merge pull request #588 from 9rnsr/enforceProp

Make some AA member functions non-property
add explicit thread_term call to replace atexit

- When calling rt_init/rt_term from ELF's .ctors/.dtors section
  atexit runs before rt_term, which causes a crash because the
  thread locks are already destroyed.
reuse rt_init/rt_term in main

- runModuleUnitTests is no longer called from rt_init
  but needs to be called separatly
Merge pull request #587 from dawgfoto/refactorMain

reuse rt_init/rt_term in main