Skip to content

Commit

Permalink
Review code main_thread and unmanaged_thread can be use for many methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Aug 11, 2023
1 parent 55fbc00 commit a0f419a
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/xtd.core/src/xtd/threading/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ bool thread::is_background() const noexcept {

thread& thread::is_background(bool value) {
if (!data_) throw invalid_operation_exception {csf_};
if (is_unmanaged_thread()) throw thread_state_exception(csf_);

if (value) data_->state |= xtd::threading::thread_state::background;
else data_->state &= ~xtd::threading::thread_state::background;
Expand Down Expand Up @@ -223,7 +222,6 @@ xtd::threading::thread_state thread::thread_state() const noexcept {

void thread::abort() {
if (!data_) throw invalid_operation_exception {csf_};
if (is_unmanaged_thread()) throw invalid_operation_exception(csf_);
if (is_unstarted() || is_suspended()) throw thread_state_exception(csf_);

data_->state |= xtd::threading::thread_state::abort_requested;
Expand All @@ -245,7 +243,6 @@ void thread::detach() {

void thread::interrupt() {
if (!data_) throw invalid_operation_exception {csf_};
if (is_unmanaged_thread() || is_main_thread()) throw invalid_operation_exception(csf_);
if (is_unstarted()) throw thread_state_exception(csf_);

if (is_wait_sleep_join() && native::thread::cancel(data_->handle)) {
Expand All @@ -263,7 +260,6 @@ void thread::join() {
}

bool thread::join(int32 milliseconds_timeout) {
if (is_unmanaged_thread()) throw invalid_operation_exception {csf_};
if (is_unstarted()) throw thread_state_exception {csf_};
if (milliseconds_timeout < timeout::infinite) throw argument_exception(csf_);

Expand All @@ -286,7 +282,6 @@ bool thread::join(int32 milliseconds_timeout) {

void thread::resume() {
if (!data_) throw invalid_operation_exception {csf_};
if (is_unmanaged_thread()) throw invalid_operation_exception(csf_);
if (is_unstarted() || !is_suspended()) throw thread_state_exception(csf_);

native::thread::resume(data_->handle);
Expand Down Expand Up @@ -341,7 +336,6 @@ thread thread::start_new(const xtd::threading::parameterized_thread_start& start

void thread::suspend() {
if (!data_) throw invalid_operation_exception {csf_};
if (is_unmanaged_thread()) throw invalid_operation_exception(csf_);
if (!is_alive()) throw thread_state_exception(csf_);

data_->state |= xtd::threading::thread_state::suspend_requested;
Expand Down

0 comments on commit a0f419a

Please sign in to comment.