Skip to content

Commit

Permalink
xtd::threading::monitor class implementation (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Sep 9, 2023
1 parent 37a3912 commit 194e75a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/xtd.core/include/xtd/threading/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ namespace xtd {
static void pulse_ptr(ptr_item obj);
static void pulse_all_ptr(ptr_item obj);
static bool try_enter_ptr(ptr_item ptr, int32 milliseconds_timeout, bool& lock_taken) noexcept;
static bool wait_ptr(ptr_item ptr, int32 milliseconds_timeout, bool exit_context) noexcept;
static bool wait_ptr(ptr_item ptr, int32 milliseconds_timeout, bool exit_context);
};
}
}
13 changes: 11 additions & 2 deletions src/xtd.core/src/xtd/threading/monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,17 @@ bool monitor::try_enter_ptr(ptr_item ptr, int32 milliseconds_timeout, bool& lock
return lock_taken;
}

bool monitor::wait_ptr(ptr_item ptr, int32 milliseconds_timeout, bool exit_context) noexcept {
return false;
bool monitor::wait_ptr(ptr_item ptr, int32 milliseconds_timeout, bool exit_context) {
monitor_item* monitor_item = nullptr;
get_static_data().monitor_items_sync.enter();
if (is_entered_ptr(ptr)) monitor_item = &get_static_data().monitor_items[ptr.first];
get_static_data().monitor_items_sync.leave();

if (monitor_item == nullptr) throw invalid_operation_exception(csf_);
if (monitor_item->thread_id != thread::current_thread().thread_id()) throw synchronization_lock_exception {csf_};

// make wait...
throw not_implemented_exception {csf_};
}

monitor::static_data& monitor::get_static_data() {
Expand Down

0 comments on commit 194e75a

Please sign in to comment.