queue

Is it possible to remove queue element by value?

时间秒杀一切 提交于 2020-01-02 03:17:06
问题 I want to remove element from queue with specific value. How to do such thing? (I am trying to create a concurrent mixture of map and queue and currently I try to implement on this answer) So I currently have such code: #ifndef CONCURRENT_QUEUED_MAP_H #define CONCURRENT_QUEUED_MAP_H #include <map> #include <deque> #include <boost/thread.hpp> #include <boost/thread/locks.hpp> template <class map_t_1, class map_t_2> class concurrent_queued_map { private: std::map<map_t_1, map_t_2> _ds; std:

Radix Sorting with using queue

假装没事ソ 提交于 2020-01-02 02:33:12
问题 I've wanted to create a radix sort implementation using queues. I couldn't figure out which part of my code has problems or which resources should I read. My code may be totally wrong but this is my implementation without any help (I haven't taken a data structures & algorithms course yet). I created a function but it didn't work. While doing research, I saw some code samples but they seemed to be more complex for me. Firstly I wanted to find the least significant digit of all integers Then

Laravel 5 Command Scheduler, How to Pass in Options

痴心易碎 提交于 2020-01-02 02:21:10
问题 I have a command that takes in a number of days as an option. I did not see anywhere in the scheduler docs how to pass in options. Is it possible to pass options in to the command scheduler? Here is my command with a days option: php artisan users:daysInactiveInvitation --days=30 Scheduled it would be: $schedule->command('users:daysInactiveInvitation')->daily(); Preferably I could pass in the option something along the lines of: $schedule->command('users:daysInactiveInvitation')->daily()-

Private inheritance in C#?

丶灬走出姿态 提交于 2020-01-02 02:01:21
问题 I'm new to C# and wondered if there is something like private inheritance in C# (like in C++) ? My problem is as follows: I want to implement a queue (name it SpecialQueue) with the following changes: The queue has a maximum number of items that can be stored in it. If the queue is full and you insert a new item, one item will be automatically poped out of the queue (the first item in the queue) and the new item will be inserted to the end of the queue. Some methods (such as peek()) provided

Element order in BlockingCollection<>

冷暖自知 提交于 2020-01-02 00:57:09
问题 I have a Download Queue implemented with BlockingCollection<> . Now I want to prioritize some Download once in a while. I thought it might be great to move some elements 'up' the Collection, like in a list, but there is no method like Remove()/AddFirst() or Move(). What's the preferred way of arranging items in a BlockingCollection<> ? 回答1: BlockingCollection<T> works by wrapping an internal IProducerConsumerCollection<T>. The default is to use a ConcurrentQueue<T> internally, but you can

How to customize blocking behavior of BlockingQueue

旧时模样 提交于 2020-01-02 00:50:35
问题 I want to create a blocking queue which blocks producer on the basis of customized rules instead of number of items in the queue. For example: Producer produces some files and puts into a queue. Consumer transfers them to a specific location after some analysis. For above scenario, I want producer waiting to produce new files if the size of total files in the queue reaches some threshold value. Queue can accept any number of files if the total size don't cross threshold value. 回答1: I would

Apache Kafka LEADER_NOT_AVAILABLE

我的未来我决定 提交于 2020-01-01 18:43:13
问题 I'm running into an issue with apache Kafka that I don't understand . I subscribe to a topic in my broker called "topic-received" . This is the code : protected String readResponse(final String idMessage) { if (props != null) { kafkaClient = new KafkaConsumer<>(props); logger.debug("Subscribed to topic-received"); kafkaClient.subscribe(Arrays.asList("topic-received")); logger.debug("Waiting for reading : topic-received"); ConsumerRecords<String, String> records = kafkaClient.poll(kafkaConfig

ActiveMQ - Removing queues programmatically

早过忘川 提交于 2020-01-01 10:05:48
问题 Fellow StackOverflowers, is there a way for me to remove a queue or a topic in ActiveMQ programmatically? I am using ActiveMQ's standard persistency, and my application requires that, on startup, all new queues be dynamically re-created (unless there are messages stored in the queue, in which case, the queue should remain to exist). I am also creating all queues programmatically through sessions. Is there an equivalent to that procedure, only to delete a queue? Querying and iterating through

Java performance problem with LinkedBlockingQueue

空扰寡人 提交于 2020-01-01 07:55:11
问题 this is my first post on stackoverflow... I hope someone can help me I have a big performance regression with Java 6 LinkedBlockingQueue . In the first thread i generate some objects which i push in to the queue In the second thread i pull these objects out. The performance regression occurs when the take() method of the LinkedBlockingQueue is called frequently. I monitored the whole program and the take() method claimed the most time overall. And the throughput goes from ~58Mb/s to 0.9Mb/s..

Bankteller console application

三世轮回 提交于 2020-01-01 07:24:29
问题 I'm making a simple application to simulate the bankteller problem . What I'm trying to simulate is: You have 4 counters in a store. 1 counter is open. Customers start coming in and enter the line for the first counter. When the fourth customer enters the line for the first counter, another counter should open. The line should be equally divided between the 2 counters.When the customer at the second counter is helped and no new customers enter the line, the counter should close. Basically 4