event-driven

How does event-driven programming help a webserver that only does IO?

删除回忆录丶 提交于 2019-12-02 08:30:31
问题 I'm considering a few frameworks/programming methods for our new backend project. It regards a BackendForFrontend implementation, which aggregates downstream services. For simplicity, these are the steps it goes trough: Request comes into the webserver Webserver makes downstream request Downstream request returns result Webserver returns request How is event-driven programming better than "regular" thread-per-request handling? Some websites try to explain, and it often comes down to something

for loop over event driven code?

℡╲_俬逩灬. 提交于 2019-12-02 05:45:02
问题 In a redis datastore I have a list of keys, I want to iterate over that list of keys and get those values from redis. The catch is I am using an event driven language, javascript via node.js If javascript were procedural I could do this function getAll(callback) { var list = redis.lrange(lrange('mykey', 0, -1); for ( var i = 0; i < list.length; i+= 1 ) { list[i] = redis.hgetall(list[i]); } callback(list); } But, I cannot, therefor.. I do this? function getAll(callback) { redis.lrange('mykey',

for loop over event driven code?

微笑、不失礼 提交于 2019-12-02 02:41:13
In a redis datastore I have a list of keys, I want to iterate over that list of keys and get those values from redis. The catch is I am using an event driven language, javascript via node.js If javascript were procedural I could do this function getAll(callback) { var list = redis.lrange(lrange('mykey', 0, -1); for ( var i = 0; i < list.length; i+= 1 ) { list[i] = redis.hgetall(list[i]); } callback(list); } But, I cannot, therefor.. I do this? function getAll(callback) { redis.lrange('mykey', 0, -1, function(err, reply) { // convert reply into messages var list = []; var index = -1; var

What is event-driven programming? [closed]

不问归期 提交于 2019-11-30 22:29:06
What is event-driven programming and has event-driven programming anything to do with threading? I came to this question reading about servers and how they handle user requests and manage data. If user sends request, server begins to process data and writes the state in a table. Why is that so? Does server stop processing data for that user and start to process data for another user or processing for every user is run in a different thread (multithread server)? Event driven programming != Threaded programming, but they can (and should) overlap. Threaded programming is used when multiple

What is event-driven programming? [closed]

微笑、不失礼 提交于 2019-11-30 18:05:54
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 months ago . What is event-driven programming and has event-driven programming anything to do with threading? I came to this question reading about servers and how they handle user requests and manage data. If user sends request, server begins to process data and writes the state in a table.

I want to wait on both a file descriptor and a mutex, what's the recommended way to do this?

谁说我不能喝 提交于 2019-11-30 08:28:25
I would like to spawn off threads to perform certain tasks, and use a thread-safe queue to communicate with them. I would also like to be doing IO to a variety of file descriptors while I'm waiting. What's the recommended way to accomplish this? Do I have to created an inter-thread pipe and write to it when the queue goes from no elements to some elements? Isn't there a better way? And if I have to create the inter-thread pipe, why don't more libraries that implement shared queues allow you to create the shared queue and inter-thread pipe as a single entity? Does the fact I want to do this at

What's the difference between event-driven and asynchronous? Between epoll and AIO?

∥☆過路亽.° 提交于 2019-11-29 19:58:10
Event-driven and asynchronous are often used as synonyms. Are there any differences between the two? Also, what is the difference between epoll and aio ? How do they fit together? Lastly, I've read many times that AIO in Linux is horribly broken. How exactly is it broken? Thanks. c-smile Events is one of the paradigms to achieve asynchronous execution. But not all asynchronous systems use events. That is about semantic meaning of these two - one is super-entity of another. epoll and aio use different metaphors: epoll is a blocking operation ( epoll_wait() ) - you block the thread until some

I want to wait on both a file descriptor and a mutex, what's the recommended way to do this?

若如初见. 提交于 2019-11-29 11:40:07
问题 I would like to spawn off threads to perform certain tasks, and use a thread-safe queue to communicate with them. I would also like to be doing IO to a variety of file descriptors while I'm waiting. What's the recommended way to accomplish this? Do I have to created an inter-thread pipe and write to it when the queue goes from no elements to some elements? Isn't there a better way? And if I have to create the inter-thread pipe, why don't more libraries that implement shared queues allow you

What's the difference between event-driven and asynchronous? Between epoll and AIO?

拥有回忆 提交于 2019-11-28 15:47:27
问题 Event-driven and asynchronous are often used as synonyms. Are there any differences between the two? Also, what is the difference between epoll and aio ? How do they fit together? Lastly, I've read many times that AIO in Linux is horribly broken. How exactly is it broken? Thanks. 回答1: Events is one of the paradigms to achieve asynchronous execution. But not all asynchronous systems use events. That is about semantic meaning of these two - one is super-entity of another. epoll and aio use

What so different about Node.js's event-driven? Can't we do that in ASP.Net's HttpAsyncHandler?

偶尔善良 提交于 2019-11-28 15:12:26
I'm not very experienced in web programming, and I haven't actually coded anything in Node.js yet, just curious about the event-driven approach . It does seems good. The article explains some bad things that could happen when we use a thread-based approach to handle requests, and should opt for a event-driven approach instead. In thread-based, the cashier/thread is stuck with us until our food/resource is ready. While in event-driven, the cashier send us somewhere out of the request queue so we don't block other requests while waiting for our food. To scale the blocking thread-based, you need