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
14
votes
3 answers

How can I avoid blocking with Java ServerSocket?

Im working on a socket listener that has to listen on 2 ports for 2 types of data( port 80 and port 81). These data are very similar as in the kind of operations that are performed on the data and are just different because they arrive n different…
ping
  • 1,229
  • 3
  • 21
  • 41
14
votes
6 answers

sending a non-blocking HTTP POST request

I have a two websites in php and python. When a user sends a request to the server I need php/python to send an HTTP POST request to a remote server. I want to reply to the user immediately without waiting for a response from the remote server. Is…
pablo
  • 141
  • 1
  • 1
  • 3
13
votes
3 answers

Javascript non-blocking scripts, why don't simply put all scripts before tag?

In order to avoid javascript to block webpage rendering, can't we just put all all our JS files/code to be loaded/executed simply before the closing tag? All JS files and code would be downloaded and executed only after the all page has…
Marco Demaio
  • 33,578
  • 33
  • 128
  • 159
13
votes
2 answers

TNonblockingServer, TThreadedServer and TThreadPoolServer, which one fits best for my case?

Our analytic server is written in c++. It basically queries underlying storage engine and returns a fairly big structured data via thrift. A typical requests will take about 0.05 to 0.6 seconds to finish depends on the request size. I noticed that…
Alex Dong
  • 975
  • 2
  • 9
  • 18
13
votes
1 answer

Java 8 CompletableFuture vs Netty Future

How does the CompletableFuture introduced in JDK 8 compare with the io.netty.util.concurrent.Future provided by Netty ? Netty documentation mentions that JDK 8 adds CompletableFuture which somewhat overlaps …
Prateek
  • 373
  • 4
  • 9
13
votes
5 answers

Atomic Instruction

What do you mean by Atomic instructions? How does the following become Atomic? TestAndSet int TestAndSet(int *x){ register int temp = *x; *x = 1; return temp; } From a software perspective, if one does not want to use non-blocking…
Sashi
  • 3,069
  • 6
  • 20
  • 18
13
votes
6 answers

How can I get non-blocking socket connect()'s?

I have a quite simple problem here. I need to communicate with a lot of hosts simultaneously, but I do not really need any synchronization because each request is pretty self sufficient. Because of that, I chose to work with asynchronous sockets,…
Tom
  • 3,115
  • 6
  • 33
  • 38
13
votes
1 answer

How to avoid blocking code in python with gevent?

I am playing around with gevent, and I am trying to understand why my code is blocking and how I can fix it. I have a pool of greenlets, and each of them talk to a thrift client which gathers data from a remote thrift server. For the purpose of the…
Martin
  • 905
  • 9
  • 19
12
votes
4 answers

Why is a function and a callback non-blocking in Node.JS?

The novice understanding of Node is that if I re-write synchronous, or in-line code, to utilize functions / callbacks, I can ensure that my code is non-blocking. I'm curious how this works in terms of the event stack. The simple example from here:…
Inc1982
  • 1,955
  • 1
  • 18
  • 32
12
votes
2 answers

Why is "Multiplexed, non-blocking I/O, [..] much more scalable than thread-oriented, blocking I/O"?

I'm reading about Channels in the JDK 7 docs (here), and stumbled upon this: Multiplexed, non-blocking I/O, which is much more scalable than thread-oriented, blocking I/O, [...] Is there a simple explanation as to why this is so?
Mads Nielsen
  • 634
  • 5
  • 16
12
votes
1 answer

Python code hangs while trying to open a named pipe for reading

I am trying to setup two way communication between a daemon and a client using named pipes. The code hangs while trying to open the named pipe used for input Why? class comm(threading.Thread): def __init__(self): self.srvoutf =…
T_Mac
  • 223
  • 3
  • 10
12
votes
1 answer

Setting stdout to non-blocking in python

Prior warning: I'm hacking around here out of curiosity. I have no specific reason to do what I'm doing below! Below is done on Python 2.7.13 on MacOS 10.12.5 I was hacking around with python and I thought it'd be interesting to see what happened if…
Andrew Parker
  • 1,425
  • 2
  • 20
  • 28
12
votes
5 answers

Volatile and Thread.MemoryBarrier in C#

To implement a lock free code for multithreading application I used volatile variables, Theoretically: The volatile keyword is simply used to make sure that all threads see the most updated value of a volatile variable; so if thread A updates the…
Jalal Said
  • 15,906
  • 7
  • 45
  • 68
12
votes
3 answers

Performing non-blocking requests? - Django

I have been playing with other frameworks, such as NodeJS, lately. I love the possibility to return a response, and still being able to do further operations. e.g. def view(request): do_something() return HttpResponse() do_more_stuff() #not…
RadiantHex
  • 24,907
  • 47
  • 148
  • 244
12
votes
1 answer

Adapting celery.task.http.URL for tornado

Celery include a module that is able to make asynchronous HTTP requests using amqp or some other celery backend. I am using tornado-celery producer for asynchronous message publishing. As I understood tornado-celery uses pika for this. The question…
Rustem K
  • 1,212
  • 11
  • 27