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:
public final boolean getAndSet(boolean newValue) { | |
boolean prev; | |
do { | |
prev = get(); | |
} while (!compareAndSet(prev, newValue)); | |
return prev; | |
} |
public final int getAndSet(int newValue) { | |
return unsafe.getAndSetInt(this, valueOffset, newValue); | |
} |
User-Agent: * | |
Allow: / | |
Disallow: /cgi-bin | |
Disallow: /booking | |
Disallow: /cont | |
Disallow: /counters | |
Disallow: /dig | |
Disallow: /chat | |
Disallow: /chat2 | |
Disallow: /css |
use std::io; | |
use futures::Future; | |
use futures::Poll; | |
use futures::Async; | |
use futures::stream::Stream; | |
use tokio_core; | |
use tokio_core::reactor; |
// 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 |
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 |
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, |
#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; | |
/// Atomic holder of `Option<Box<T>>`. | |
/// | |
/// `AtomicBoxOption` owns a pointer, thus it `drop` content on self `drop`. |