Skip to main content

biconnect_components

Function biconnect_components 

Source
pub fn biconnect_components<P, C1, C2>(
    provider: &Arc<Component<C1>>,
    requirer: &Arc<Component<C2>>,
) -> Result<TwoWayChannel<P, C1, C2>, TryDualLockError>
where P: Port + 'static, C1: ComponentDefinition + 'static + Provide<P> + ProvideRef<P>, C2: ComponentDefinition + 'static + Require<P> + RequireRef<P>,
Expand description

Connect two components on their instances of port type P.

The component providing the port must be given as first argument, and the requiring component second.

This function can fail with a TryDualLockError, if one of the mutexes can not be acquired immediately.

ยงExample

use kompact::prelude::*;


let system = KompactConfig::default().build().wait().expect("system");
let c1 = system.create(TestComponent1::new);
let c2 = system.create(TestComponent2::new);
biconnect_components::<TestPort,_,_>(&c1, &c2).expect("connection");