Open bigbao9494 opened 5 years ago
modify test code,it works failed:
class int_handler : public disruptor4cpp::event_handler { public: int_handler() = default; virtual ~int_handler() = default; virtual void on_start() { } virtual void on_shutdown() { } virtual void on_event(int& event, int64_t sequence, bool end_of_batch) { std::cout << "Received integer: " << event << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(10)); //----------modify---------- } virtual void on_timeout(int64_t sequence) { } virtual void on_event_exception(const std::exception& ex, int64_t sequence, int* event) { } virtual void on_start_exception(const std::exception& ex) { } virtual void on_shutdown_exception(const std::exception& ex) { } };
int main(int argc, char* argv[]) { using namespace disruptor4cpp;
// Create the ring buffer. //ring_buffer<int, 1024, busy_spin_wait_strategy, producer_type::multi> ring_buffer; //----------modify---------- ring_buffer<int, 64, busy_spin_wait_strategy, producer_type::multi> ring_buffer; // Create and run the consumer on another thread. auto barrier = ring_buffer.new_barrier(); int_handler handler; batch_event_processor<decltype(ring_buffer)> processor(ring_buffer, std::move(barrier), handler); std::thread processor_thread([&processor] { processor.run(); }); // Publish some integers. for (int i = 0; i < 1000; i++) { int64_t seq = ring_buffer.next(); ring_buffer[seq] = i; ring_buffer.publish(seq); } // Stop the consumer. //----------modify---------- //std::this_thread::sleep_for(std::chrono::seconds(1)); //processor.halt(); processor_thread.join(); return 0;
}
What did you see and what do you expect to see?
sorry it's my mistake.
modify test code,it works failed:
class int_handler : public disruptor4cpp::event_handler
{
public:
int_handler() = default;
virtual ~int_handler() = default;
virtual void on_start() { }
virtual void on_shutdown() { }
virtual void on_event(int& event, int64_t sequence, bool end_of_batch)
{
std::cout << "Received integer: " << event << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(10)); //----------modify----------
}
virtual void on_timeout(int64_t sequence) { }
virtual void on_event_exception(const std::exception& ex, int64_t sequence, int* event) { }
virtual void on_start_exception(const std::exception& ex) { }
virtual void on_shutdown_exception(const std::exception& ex) { }
};
int main(int argc, char* argv[]) { using namespace disruptor4cpp;
}