improve locking to prevent race condition
stratum could respond faster than we are able to add the sent share into the hash, which could cause memory leaks
immediately exit threads if doing hard reset
Hard reset only when gpu-threads or devices are changed, but not when algorithm is changed.
Also a little refactor.

Conflicts:
	sgminer.c