Skip to content

Commit

Permalink
Fix rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Sep 24, 2023
1 parent 38ae7ba commit c8a8b3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions rustler/src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use std::{marker::PhantomData, mem::MaybeUninit};

use rustler_sys::{ErlNifMonitor, ErlNifPid, ErlNifResourceDown};

use super::{Binary, Decoder, Encoder, Env, Error, NifResult, Term};
use super::{Binary, Decoder, Encoder, Env, Error, LocalPid, Term};
use crate::wrapper::{
c_void, resource, NifResourceFlags, MUTABLE_NIF_RESOURCE_HANDLE, NIF_ENV, NIF_RESOURCE_TYPE,
LocalPid,
};
use crate::NifResult;

/// Re-export a type used by the `resource!` macro.
#[doc(hidden)]
Expand Down
9 changes: 7 additions & 2 deletions rustler_tests/native/rustler_test/src/test_resource.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use rustler::{Binary, Env, LocalPid, Monitor, MonitorResource, ResourceArc, ResourceArcMonitor};
use std::sync::{RwLock, Mutex};
use std::sync::{Mutex, RwLock};

pub struct TestResource {
test_field: RwLock<i32>,
Expand Down Expand Up @@ -103,6 +103,7 @@ pub fn resource_make_with_binaries() -> ResourceArc<WithBinaries> {
})
}

#[rustler::nif]
pub fn monitor_resource_make() -> ResourceArc<TestMonitorResource> {
ResourceArc::new(TestMonitorResource {
inner: Mutex::new(TestMonitorResourceInner {
Expand Down Expand Up @@ -137,7 +138,11 @@ pub fn resource_make_binary_from_vec(env: Env, resource: ResourceArc<WithBinarie
}

#[rustler::nif]
pub fn monitor_resource_monitor(env: Env, resource: ResourceArc<TestMonitorResource>, pid: LocalPid) {
pub fn monitor_resource_monitor(
env: Env,
resource: ResourceArc<TestMonitorResource>,
pid: LocalPid,
) {
let mut inner = resource.inner.lock().unwrap();
inner.mon = resource.monitor(Some(&env), &pid);
assert!(inner.mon.is_some());
Expand Down

0 comments on commit c8a8b3d

Please sign in to comment.