Questions tagged [blocking]

Blocking mode I/O blocks the issuing thread until the operation transfers at least one byte or an error or end of stream occurs. Blocking algorithms refer to an operation in multithreaded environment which temporarily restricts access to some resources to a single thread, thus blocking all other ones. It isn't clear which this tag is intended for.

1679 questions
10
votes
6 answers

How can I make a program wait for a button press in javascript?

I need to modify some legacy javascript code. There's a place where I want to wait until the user presses one of two buttons and then continue with the program flow (like prompt() function). How can this be achieved ?
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
10
votes
3 answers

How do I write a blocking synchronous method in Javascript?

I'm trying to mock out a method which takes a long time for testing purposes but can't find a good way to do this in Javascript. Any good approaches besides writing a very long for loop?
Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197
9
votes
3 answers

Semaphore queues

I'm extending the functionality of a semaphore. I ran into a roadblock when I realized I don't know the implementation of an actual semaphore and to make sure my code ran correctly, I needed to know this. I know a semaphore works by blocking…
user82229
  • 93
  • 1
  • 1
  • 3
9
votes
7 answers

What is the purpose of hard disk direct memory access?

At first glance it seems like a good idea to let the hard disk write to RAM on its own, without CPU instructions copying data, particularly with the success of asynchronous networking in mind. But the Wikipedia article on Direct Memory Access (DMA)…
henle
  • 473
  • 1
  • 4
  • 16
9
votes
1 answer

How can I force a thread that is blocked reading from a file to resume in Rust?

Because Rust does not have have the built-in ability to read from a file in a non-blocking manner, I have to spawn a thread which reads the file /dev/input/fs0 in order to get joystick events. Suppose the joystick is unused (nothing to read), so the…
Pentagolo
  • 121
  • 6
9
votes
2 answers

Async code appears to be partially blocking when calling multiple async tasks in a row (using HttpClient)

I've been trying to learn C#'s async with HttpClient and have come across an issue where I can't figure out what's happening. What I want to do: Send multiple HttpClient requests in one go and have the responses processed individually as soon as…
undercurrent
  • 285
  • 1
  • 2
  • 12
9
votes
3 answers

How does Linux blocking I/O actually work?

In Linux, when you make a blocking i/o call like read or accept, what actually happens? My thoughts: the process get taken out of the run queue, put into a waiting or blocking state on some wait queue. Then when a tcp connection is made (for accept)…
tgguy
  • 161
  • 1
  • 2
  • 3
9
votes
2 answers

Server sent events with Flask/Redis: how can more than one client view a stream?

I have multiple clients trying to connect to a server sent events stream at /stream. This works with a single client, but attempting to connect any more clients results in the new client becoming indefinitely blocked waiting for data. If I send more…
Chris Down
  • 1,590
  • 1
  • 14
  • 25
9
votes
1 answer

What methods are blocking in Javascript?

I'm trying to override the standard confirm() method in Javascript (make a nice UI and stuff). I've read a 100 posts that it "can't be done", but I don't want to give up until I have given it a fair shot. :) So, the real problem is of course that…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
9
votes
2 answers

using QTextStream to read stdin in a non-blocking fashion

Using Qt, I'm attempting to read the contents of the stdin stream in a non-blocking fashion. I'm using the QSocketNotifier to alert me when the socket has recieved some new data. The setup for the notifier looks like this: QSocketNotifier *pNot =…
Thomi
  • 11,647
  • 13
  • 72
  • 110
9
votes
2 answers

Interrupting Java DataInputStream readFully()

I have a Java applet that streams video (MJPEG) from a server. I wrote a proxy server in C# (Windows service) to put between the applet and multiple video servers. A HTML/CSS/Js frontend is used along with the Java applet. All functionality works…
mittmemo
  • 2,062
  • 3
  • 20
  • 27
8
votes
2 answers

How to create a simple c# http monitor/blocker?

I was reading that question (How to create a simple proxy in C#?) that is near of my wishes. I simply want develop a c# app that, by example, monitors Firefox, IE, etc and logs all navigated pages. Depending of the visited page, I want to block the…
Click Ok
  • 8,700
  • 18
  • 70
  • 106
8
votes
1 answer

Proper way of dealing with blocking code using Kotling coroutines

Suppose I have a blocking function because of some third party library. Something along these lines: fun useTheLibrary(arg: String): String { val result = BlockingLibrary.doSomething(arg) return result } Invocations to…
Pablo Fernandez
  • 103,170
  • 56
  • 192
  • 232
8
votes
1 answer

How to stop a thread which is blocking on a named pipe in Python?

I have a class which subclasses threading.Thread. It's sole responsibility is putting messages read from a UNIX named pipe to a queue.Queue object (so that other threads can process these values later). Example code: class PipeReaderThread(Thread): …
krispet krispet
  • 1,648
  • 1
  • 14
  • 25
8
votes
4 answers

What is the difference between a blocking and non-blocking read?

Add to the above question the concept of a wait/no wait indicator as a parameter to a ReadMessage function in a TCP/IP or UDP environment. A third party function description states that: This function is used to read a message from a queue which…
user553514
  • 217
  • 2
  • 4
  • 14