Questions tagged [nonblocking]

Non-blocking mode I/O either transfers at least one byte or returns immediately with an error or end of stream. Non-blocking algorithms refer to use of concurrency without the usual mutual exclusion primitives, guaranteeing that thread operations will not block indefinitely. This is usually handled with atomic value modification (increment/decrement) and/or reading (compare-and-exchange) operations.. It isn't clear which this tag is intended for.

1597 questions
10
votes
2 answers

Is there a way to de-register a selector on a socket channel

This is a pretty straight forward question, but I have found a need to unregister a selector overlooking my socket channel for java. SocketChannel client = myServer.accept(); //forks off another client socket client.configureBlocking(false);//this…
Dr.Knowitall
  • 10,080
  • 23
  • 82
  • 133
9
votes
2 answers

ruby non-blocking line read

I'm trying to read a line from an io in a non-blocking way. Unfortunately readline blocks. I think I can solve this with read_nonblock with an additional buffer where I store partial result, check if there are multiple lines in the buffer, etc.. but…
Karoly Horvath
  • 94,607
  • 11
  • 117
  • 176
9
votes
1 answer

Confused about OpenSSL non-blocking I/O

In general, the OpenSSL library (C API) seems to offer two ways to do everything: you can either use plain system sockets configured to your liking, or you can use OpenSSL BIO objects which are sort of like streams. However, I'm often confused by…
Channel72
  • 24,139
  • 32
  • 108
  • 180
9
votes
5 answers

Python - How can I make this code asynchronous?

Here's some code that illustrates my problem: def blocking1(): while True: yield 'first blocking function example' def blocking2(): while True: yield 'second blocking function example' for i in blocking1(): print 'this…
dave
  • 7,717
  • 19
  • 68
  • 100
9
votes
2 answers

Monitoring file using inotify

I am using inotify to monitor a local file, for example "/root/temp" using inotify_add_watch(fd, "/root/temp", mask). When this file is deleted, the program will be blocked by read(fd, buf, bufSize) function. Even if I create a new "/root/temp"…
user572138
  • 463
  • 4
  • 6
  • 13
9
votes
4 answers

C socket blocking call

I wonder about the behaviour of socket on blocking and nonblocking actions. What happens to threads blocking on socket when the socket blocking mode changes ? Here is the scenario; thread1(T1) creates a UDP socket and fd = socket(AF_INET ,…
Qxtrml
  • 177
  • 2
  • 7
9
votes
2 answers

What is the preferred way of performing non blocking I/O in Ruby?

If say I want to retrieve a web page for parsing, but not block the CPU while the I/O is taking place. Is there something equivalent to Python's Eventlet library?
Fast Fish
  • 385
  • 1
  • 3
  • 7
9
votes
3 answers

C /C++ Lock-free (or nonblocking) Ring Buffer that OVERWRITES oldest data?

I'm trying to find a way to make a Lock Free OR Non-blocking way to make a Ring Buffer for single consumer / single consumer that will over-write the oldest data int the buffer. I've read a lot of lock-free algorithms that work when you "return…
Nik
  • 239
  • 4
  • 10
9
votes
4 answers

Non-Blocking File IO in Java

I want to write to a named pipe (already created) without blocking on the reader. My reader is another application that may go down. If the reader does go down, I want the writer application to keep writing to that named pipe. Something like a this…
Gautam
  • 91
  • 1
  • 1
  • 2
9
votes
2 answers

If a web server is non-blocking, does this mean it is handling IO the same as node.js?

I will soon be using a server named Undertow. The website says: Undertow is a flexible performant web server written in java, providing both blocking and non-blocking API’s based on NIO If Undertow allows non-blocking, is that the same as…
johnny
  • 19,272
  • 52
  • 157
  • 259
9
votes
2 answers

Why is a non-blocking TCP connect() occasionally so slow on Linux?

I was trying to measure the speed of a TCP server I'm writing, and I've noticed that there might be a fundamental problem of measuring the speed of the connect() calls: if I connect in a non-blocking way, connect() operations become very slow after…
pts
  • 80,836
  • 20
  • 110
  • 183
9
votes
2 answers

libuv uses blocking file system calls internally – Why? How?

I just learned that Node.js crown jewel libuv uses blocking system calls for file operations. The asynchronous behavior is implemented with threads! That raises two questions (I only care about Unix): Why is it not using the non-blocking filesystem…
Robert Siemer
  • 32,405
  • 11
  • 84
  • 94
8
votes
1 answer

Non-blocking Sockets vs BeginXXX vs SocketAsyncEventArgs

Can anyone please enlighten me about current .NET socket techniques? Non-blocking sockets If I set Socket.Blocking = false and use async operations - what will happen? Is there any method of polling multiple non-blocking sockets instead of checking…
Aquilae
  • 93
  • 4
8
votes
3 answers

Java CompletableFuture for sequential code

My new team is writing a Java gRPC service and to ensure that we never block the request thread we ended-up wrapping more or less ALL methods inside a CompletableFuture even if those endpoints are conceptually a sequential list of operation (no…
HLP
  • 2,142
  • 5
  • 19
  • 20
8
votes
4 answers

Is there a non blocking method for host resolution in WINAPI?

There's getaddrinfo() for blocking host resolution, but is there a non blocking method?
Plumenator
  • 1,682
  • 3
  • 20
  • 49