producer-consumer

Using pthread condition variable with rwlock

不羁岁月 提交于 2020-01-22 09:44:20
问题 I'm looking for a way to use pthread rwlock structure with conditions routines in C++. I have two questions: First: How is it possible and if we can't, why ? Second: Why current POSIX pthread have not implemented this behaviour ? To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing with one shared array. The consumer will cond_wait when the array is empty, but rdlock when reading some elems. The producer will wrlock when adding(+signal) or removing

Using pthread condition variable with rwlock

你说的曾经没有我的故事 提交于 2020-01-22 09:39:10
问题 I'm looking for a way to use pthread rwlock structure with conditions routines in C++. I have two questions: First: How is it possible and if we can't, why ? Second: Why current POSIX pthread have not implemented this behaviour ? To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing with one shared array. The consumer will cond_wait when the array is empty, but rdlock when reading some elems. The producer will wrlock when adding(+signal) or removing

Using pthread condition variable with rwlock

家住魔仙堡 提交于 2020-01-22 09:38:08
问题 I'm looking for a way to use pthread rwlock structure with conditions routines in C++. I have two questions: First: How is it possible and if we can't, why ? Second: Why current POSIX pthread have not implemented this behaviour ? To understand my purpose, I explain what will be my use: I've a producer-consumer model dealing with one shared array. The consumer will cond_wait when the array is empty, but rdlock when reading some elems. The producer will wrlock when adding(+signal) or removing

Thread-safe async byte queue

こ雲淡風輕ζ 提交于 2020-01-14 19:15:20
问题 I've got a callback method that is called whenever new data is available: public delegate void DataCallback( byte[] buffer, int offset, int count); I want to wrap this in a class that implements an interface similar to this: public interface IDataSource { IAsyncResult BeginRead( byte[] buffer, int offset, int size, TimeSpan timeout, AsyncCallback callback, object state); int EndRead( IAsyncResult asyncResult); int Read( byte[] buffer, int offset, int size, TimeSpan timeout); } This is

shmat() is returning a different “shmaddr” for same “shmkey”

匆匆过客 提交于 2020-01-10 05:18:05
问题 Here's my setup... /* Bounded Buffer item structure */ struct item { int id; /* string index value */ char str[80]; /* string value */ }; /* Structure for the shared memory region */ typedef struct { int debug; /* debug flag */ int in; /* index of next empty slot */ int out; /* index of next full slot */ char MUTEXname[32]; /* name of the MUTEX semaphore */ char EMPTYname[32]; /* name of the EMPTY semaphore */ char FULLname[32]; /* name of the FULL semaphore */ struct item buff[BUFFSIZE]; /*

SegFault with Producer/Consumer File Copy

不羁岁月 提交于 2020-01-06 12:37:07
问题 back with another segfault. Not sure why, as this readdir line is the same one i've been using in other file copy assignments. Below is the code I crafted in lieu of the assignment shared here. I have commented where the segfault occurs in hopes of aiding better minds find my flaw! This is copyDirs.cpp //cmd: ./a.out [#ofConsumerThreads] [src directory] [dest directory] #include "copyDirs.h" int main(int ac,char* av[]) { pthread_mutex_init(&buflock,NULL); pthread_t prodT; if(ac == 4) { int

SegFault with Producer/Consumer File Copy

核能气质少年 提交于 2020-01-06 12:36:10
问题 back with another segfault. Not sure why, as this readdir line is the same one i've been using in other file copy assignments. Below is the code I crafted in lieu of the assignment shared here. I have commented where the segfault occurs in hopes of aiding better minds find my flaw! This is copyDirs.cpp //cmd: ./a.out [#ofConsumerThreads] [src directory] [dest directory] #include "copyDirs.h" int main(int ac,char* av[]) { pthread_mutex_init(&buflock,NULL); pthread_t prodT; if(ac == 4) { int

How to read data from topic using kafka-node?

懵懂的女人 提交于 2020-01-04 05:39:28
问题 I have topic that i have to read from kafka server so for that i just need to create consumer that can read data from kafka topic, I always get error topic does not exist. 1- How can i make sure kafka connection is established ? 2- How to get the data from specific topic in kafka ? main.js var kafka = require('kafka-node'); var config = require('./config.js'); var kafkaConn = config.kafkaCon.dit; var HighLevelConsumer = kafka.HighLevelConsumer; //var HighLevelProducer = kafka

Producer Consumer-Average Wait times not outputting/buffer query

为君一笑 提交于 2020-01-03 06:32:26
问题 I am currently making a hypothetical producer consumer problem using java. The object is to have an operating system which is 1000 bytes, but only 500 bytes available to use for threads as 500 bytes have already been consumed by drivers and other operations. The threads are as follows: A thread to start a BubbleWitch2 session of 10 seconds, which requires 100 bytes of RAM per second A thread to start a Spotify stream of 20 seconds, which requires 250 bytes of RAM per second You should also

Can producer find the additions and removals of brokers in Kafka 0.8?

六月ゝ 毕业季﹏ 提交于 2020-01-01 19:36:14
问题 We knowthat, in kafka 0.7, we can specify zk.connect for producer, so producer can find the additions and removals of broker. But in kafka 0.8, we can't specify zk.connect for producer. Can producer in kafka 0.8 find that? If not, the scalability of the system is not worse than the 0.7 version? 回答1: You can still use a ZooKeeper client to retrieve the broker list: ZkClient zkClient = new ZkClient("localhost:2108", 4000, 6000, new BytesPushThroughSerializer()); List<String> brokerList =