queue

Mixed Video Type Content queued in an AVQueuePlayer on iPhone

余生长醉 提交于 2019-12-12 05:35:36
问题 I'd like to start of by apologizing for this ridiculously long post, but I tried to provide as much code and data as possible for you to refer to. I am working on a video project where I will need the flexibility of the AVQueuePlayer (foremost the ability to scale and layout the video layer freely, as well as creating my customized controls). Problem is, I need to be able to mix video content of different types (in this case progressive download .mp4 and http streaming .m3u8). Here's where

How would i sort a queue using only one additional queue

三世轮回 提交于 2019-12-12 05:15:04
问题 So basically, Im asked to sort a queue, and i can only use one helper queue , and am only allowed constant amount of additional memory. How would i sort a queue using only one additional queue ? 回答1: Personally, I don't like interview questions with arbitrary restrictions like this, unless it actually reflects the conditions you have to work with at the company. I don't think it actually finds qualified candidates or rather, I don't think it accurately eliminates unqualified ones. When I did

How to let selector that socketchannel key change in java nio

微笑、不失礼 提交于 2019-12-12 05:02:25
问题 I have question on usage java nio and hope someone who has a lot of java nio knowledge can help me to clarify some misconcept. I am using java nio socket. It is possible that the write buffer is filled up using socketchannel.write(). In this case, the remaining buffer is queued and key is changed to OP_WRITE. One of my scenario is that the queue length is pretty long. Each time before call selector.select(),I change key to OP_WRITE from another queue called pendingRequest. But I find since

Decrementing value stored in a queue

巧了我就是萌 提交于 2019-12-12 04:13:35
问题 I'm working on a queue project where the program is simulating a grocery store. In my program, I have a method call that sets up a random variable that represents the time that it takes to service the customer in queue. The total iterations are 60, signifying minutes. Say if the first customer is given a 4 minute wait time, I need to be able to decrement the time after each minute until it reaches 0. I cannot figure out how to decrement the value stored in the queue named myQueue . Any

what is distributed queue?

旧城冷巷雨未停 提交于 2019-12-12 03:56:06
问题 My Understanding :- A distributed destination is a single, logical(not physical) destination to a client which internally contains set of physical destinations (queues or topics) . It helps in scalable applications in terms of High availability(HA) and Load Balancing(LB). So when i do distributedQueue.put(someObject) , distributed queue will put the object on one of the phyicalQueue and also maintains some meta data to record which object lies on which on which queue Now when i do

Circular Arrays in Queues

跟風遠走 提交于 2019-12-12 02:39:31
问题 How is mod used to determine the beginning and end of a circular array in a queue? 回答1: Well, usually you keep track of the index of the first element, and the current size. If the size is equal to the size of the array, that means the array is full. Enqueuing a new item then requires you to grow the array. Otherwise, you just write to element (start + size + 1) % array_size . When you dequeue an element, you just take the element at start , overwrite it with null to allow for garbage

Python 3.4 Comms Stream Delegate - Non-blocking recv and send - data out from asyncio

Deadly 提交于 2019-12-12 02:07:58
问题 I'm putting together a client server app on RPi. It has a main thread which creates a comms thread to talk to an iOS device. The main thread creates an asyncio event loop and a sendQ and a recvQ and passes them as args to the commsDelegate main method in the comms thread. The trouble I'm having is when iOS device connects, it needs to receive unsolicited data from this Python app as soon as the data becomes available and it needs to be able to send data up to the Python app. So send and

Go worker pool with repetitive queue structure

家住魔仙堡 提交于 2019-12-12 01:45:02
问题 I'm trying make worker pool with looped queue. Is my code idiomatic for Go? And how can I solve concurrent access to *Item ? Pool processing 1 item at time and *Item don't shared between workers, but sometimes I need change *Item from main thread. Should I place mutex at every *Item and when I should lock/unlock it? Or maybe some other structure is possible? var items = make(map[uint8]*Item) func worker(queue, done chan uint8) { for id := range queue { item := items[id] // get from http

sequential event processing via executorservice

你说的曾经没有我的故事 提交于 2019-12-12 01:34:42
问题 I have an event queue to process. A thread adds events to the queue. I have created a runnable Task that in the run method does all which is necessary to process the event. I have declared an Executors.newCachedThreadPool(); and I execute each Task. public class EventHandler { private static final ExecutorService handlers = Executors.newCachedThreadPool(); public void handleNextEvent(AnEvent event){ handlers.execute(new Task(evt)); } public class Task implements Runnable{ @Override public

How to batch asynchronous web requests performed using a comprehension in python?

拟墨画扇 提交于 2019-12-12 00:51:41
问题 not sure if this is possible, spend some time looking at what seem like similar questions, but still unclear. For a list of website urls, I need to get the html as a starting point. I have a class that contains a list of these urls and the class returns a custom iterator that helps me iterate through these to get the html (simplified below) class Url: def __init__(self, url) self.url = url def fetchhtml(self) import urllib2 response = urllib2.urlopen(self.url) return response.read() class