Lengthy explanation why patch works.
Sender part is simple: it (either pushes a message or sets "closed" flag) and then calls notify if any task is registered.
The interesting part is function
Function starts with optimistic pop:
| ; ModuleID = 'xx.cgu-0.rs' | |
| source_filename = "xx.cgu-0.rs" | |
| target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" | |
| target triple = "x86_64-apple-darwin" | |
| %str_slice = type { i8*, i64 } | |
| %"alloc::vec::Vec<u8>" = type { %"alloc::raw_vec::RawVec<u8, alloc::heap::HeapAlloc>", [0 x i8], i64, [0 x i8] } | |
| %"alloc::raw_vec::RawVec<u8, alloc::heap::HeapAlloc>" = type { %"core::ptr::Unique<u8>", [0 x i8], i64, [0 x i8], %"alloc::heap::HeapAlloc", [0 x i8] } | |
| %"core::ptr::Unique<u8>" = type { %"core::nonzero::NonZero<*const u8>", [0 x i8], %"core::marker::PhantomData<u8>", [0 x i8] } | |
| %"core::nonzero::NonZero<*const u8>" = type { i8*, [0 x i8] } |
| struct CyclicBarrierShared { | |
| count: u32, | |
| mutex: Mutex<(u32, bool)>, | |
| condv: Condvar, | |
| } | |
| struct CyclicBarrier { | |
| shared: Arc<CyclicBarrierShared>, | |
| } |
| use std::boxed::Box; | |
| use std::sync::atomic::AtomicPtr; | |
| use std::sync::atomic::Ordering; | |
| use std::ptr; | |
| use std::mem; | |
| /// Atomic holder of `Option<Box<T>>`. | |
| /// | |
| /// `AtomicBoxOption` owns a pointer, thus it `drop` content on self `drop`. |
| #include <stdio.h> | |
| #include <pthread.h> | |
| int main() { | |
| pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; | |
| pthread_cond_t condvar = PTHREAD_COND_INITIALIZER; | |
| int r = pthread_mutex_lock(&mutex); | |
| if (r != 0) { | |
| perror("pthread_mutex_lock"); | |
| return 1; |
| use std::boxed::Box; | |
| use std::sync::atomic::AtomicPtr; | |
| use std::sync::atomic::Ordering; | |
| use std::ptr; | |
| use std::mem; | |
| /// Max value for flag stored in `AtomicBoxOrFlag` | |
| /// `3` is safe value, because pointers are at least 4-byte aligned. | |
| /// Although in practice `malloc` never return small addresses, |
| package org.asynchttpclient.future; | |
| import java.util.ArrayList; | |
| import java.util.concurrent.CompletableFuture; | |
| import java.util.concurrent.ExecutionException; | |
| import java.util.concurrent.TimeUnit; | |
| import java.util.concurrent.TimeoutException; | |
| /** | |
| * @author Stepan Koltsov |
| // HTTP/2 request of response stream is a sequence of frames. | |
| // Header frames can be interleaves with data frames. | |
| enum HttpStreamPart { | |
| Headers(Vec<Header>), | |
| Body(Vec<u8>), | |
| } | |
| // To be implemented by user. | |
| // | |
| // Server may start sending response before |
| use std::io; | |
| use futures::Future; | |
| use futures::Poll; | |
| use futures::Async; | |
| use futures::stream::Stream; | |
| use tokio_core; | |
| use tokio_core::reactor; |
| User-Agent: * | |
| Allow: / | |
| Disallow: /cgi-bin | |
| Disallow: /booking | |
| Disallow: /cont | |
| Disallow: /counters | |
| Disallow: /dig | |
| Disallow: /chat | |
| Disallow: /chat2 | |
| Disallow: /css |