Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🍏 iOS threading, initial work #1644

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ ndk-glue = "0.1.0"

[target.'cfg(target_os = "ios")'.dependencies]
objc = "0.2.3"
dispatch = "0.2.0"

[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.20"
Expand Down
20 changes: 1 addition & 19 deletions src/platform_impl/ios/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,12 @@ impl Deref for MonitorHandle {
type Target = Inner;

fn deref(&self) -> &Inner {
unsafe {
assert_main_thread!(
"`MonitorHandle` methods can only be run on the main thread on iOS"
);
}
&self.inner
}
}

impl DerefMut for MonitorHandle {
fn deref_mut(&mut self) -> &mut Inner {
unsafe {
assert_main_thread!(
"`MonitorHandle` methods can only be run on the main thread on iOS"
);
}
&mut self.inner
}
}
Expand All @@ -158,14 +148,6 @@ impl Clone for MonitorHandle {
}
}

impl Drop for MonitorHandle {
fn drop(&mut self) {
unsafe {
assert_main_thread!("`MonitorHandle` can only be dropped on the main thread on iOS");
}
}
}

impl fmt::Debug for MonitorHandle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#[derive(Debug)]
Expand All @@ -190,9 +172,9 @@ impl fmt::Debug for MonitorHandle {
impl MonitorHandle {
pub fn retained_new(uiscreen: id) -> MonitorHandle {
unsafe {
assert_main_thread!("`MonitorHandle` can only be cloned on the main thread on iOS");
let () = msg_send![uiscreen, retain];
}

MonitorHandle {
inner: Inner { uiscreen },
}
Expand Down
Loading