summaryrefslogtreecommitdiffstats
path: root/src/router/workers.rs
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-26 15:01:47 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2019-08-26 15:01:47 +0200
commite16151419d710194f5dfb24dd1a71e04add4964e (patch)
tree857804b5be9ca8ee2033abaf9d97f264f36d5e13 /src/router/workers.rs
parentUpdate the blake2 crate to fix bug upstream (diff)
downloadwireguard-rs-e16151419d710194f5dfb24dd1a71e04add4964e.tar.xz
wireguard-rs-e16151419d710194f5dfb24dd1a71e04add4964e.zip
Work on callback structure for cryptkey router
Diffstat (limited to 'src/router/workers.rs')
-rw-r--r--src/router/workers.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/router/workers.rs b/src/router/workers.rs
index 2f7977c..4942491 100644
--- a/src/router/workers.rs
+++ b/src/router/workers.rs
@@ -10,6 +10,8 @@ use std::sync::mpsc::{sync_channel, Receiver, TryRecvError};
use std::sync::{Arc, Weak};
use std::thread;
+use super::types::{Opaque, Callback};
+
#[derive(PartialEq)]
enum Operation {
Encryption,
@@ -32,7 +34,7 @@ pub struct JobInner {
pub type JobBuffer = Arc<spin::Mutex<JobInner>>;
pub type JobParallel = (Arc<thread::JoinHandle<()>>, JobBuffer);
-pub type JobInbound = (Weak<DecryptionState>, JobBuffer);
+pub type JobInbound<T> = (Weak<DecryptionState<T>>, JobBuffer);
pub type JobOutbound = JobBuffer;
/* Strategy for workers acquiring a new job:
@@ -80,10 +82,10 @@ fn wait_recv<T>(stopped: &AtomicBool, recv: &Receiver<T>) -> Result<T, TryRecvEr
return Err(TryRecvError::Disconnected);
}
-pub fn worker_inbound(
- device: Arc<DeviceInner>, // related device
- peer: Arc<PeerInner>, // related peer
- recv: Receiver<JobInbound>, // in order queue
+pub fn worker_inbound<T : Opaque>(
+ device: Arc<DeviceInner<T>>, // related device
+ peer: Arc<PeerInner<T>>, // related peer
+ recv: Receiver<JobInbound<T>>, // in order queue
) {
loop {
match wait_recv(&peer.stopped, &recv) {
@@ -108,9 +110,9 @@ pub fn worker_inbound(
}
}
-pub fn worker_outbound(
- device: Arc<DeviceInner>, // related device
- peer: Arc<PeerInner>, // related peer
+pub fn worker_outbound<T : Opaque>(
+ device: Arc<DeviceInner<T>>, // related device
+ peer: Arc<PeerInner<T>>, // related peer
recv: Receiver<JobOutbound>, // in order queue
) {
loop {