void producer(void) { for (int i = 0; i != iterations; ++i) { int value = ++producer_count; while (!spsc_queue.push(value)) ; } }
/* * === FUNCTION ====================================================================== * Name: producer * Description: 简单的获取图像 * ===================================================================================== */ void producer(void) { while (true) { cap.read(img); /* 获取图像 */ spsc_queue.push(img); /* 加入到缓存队列中 */ } }
void rng_producer(void) { float *arr = new float[RNG_ARRAY_SIZE]; int produced, producer_count; while (!rng_producer_done) { producer_count = 0; /* Generate n floats on device */ curandGenerateNormal(gen, devData, RNG_ARRAY_SIZE, 0.0, 1.0); /* Copy device memory to host */ cudaMemcpy(arr, devData, RNG_ARRAY_SIZE * sizeof(float), cudaMemcpyDeviceToHost); while (producer_count < RNG_ARRAY_SIZE && !rng_producer_done) while ( produced = spsc_queue.push(&arr[producer_count], RNG_ARRAY_SIZE -producer_count) ) producer_count = producer_count + produced; } delete(arr); }
inline bool Queue(ISqlStmt_t query) { return m_Queue.push(query) && ++m_UnprocessedQueries; }
inline void Call(Callback_t callback) { m_Queue.push(callback); }