void basic_http_connection_impl::close(bool greaceful)
	{
		if (CLOSED==state_)
			return;

		set_cancel();
		if (life_timer_)
		{
			life_timer_->cancel();
			life_timer_.reset();
		}
		if (conn_retry_timer_)
		{
			conn_retry_timer_->cancel();
			conn_retry_timer_.reset();
		}
		connection_=NULL;
		if (greaceful&&!send_bufs_.empty())
		{
			state_=CLOSING;
		}
		else
		{
			error_code ec;
			socket_impl_->async_close(
				boost::bind(&this_type::__on_shutdown,socket_impl_,_1)
				);
			state_=CLOSED;
		}
	}
Beispiel #2
0
void reslimit::dec_cancel() {
    #pragma omp critical (reslimit_cancel)
    {
        if (m_cancel > 0) {
            set_cancel(m_cancel-1);
        }
    }
}
Beispiel #3
0
 void solver_exp::init() {
     m_atom2bvar.reset();
     if (m_sat)
         m_sat->collect_statistics(m_stats);
     #pragma omp critical (smt_solver_exp)
     {
         m_sat = alloc(sat::solver, m_params, &m_bridge);
     }
     m_arith.collect_statistics(m_stats);
     m_arith.reset();
     set_cancel(m_cancel);
 }
Beispiel #4
0
		void async_wait(const duration_type& expiry_duration)
		{
			set_cancel();
			next_op_stamp();

			error_code ec;
			status_ |= ASYNC_WAITING;
			deadline_timer_.expires_from_now(expiry_duration, ec);
			deadline_timer_.async_wait(
				make_alloc_handler(boost::bind(&this_type::handle_timeout, 
				SHARED_OBJ_FROM_THIS, _1, false, op_stamp()))
				);
		}
Beispiel #5
0
		void cancel()
		{
			error_code ec;
			deadline_timer_.cancel(ec);
			repeat_times_ = 0;
			status_ = NOT_WAITING;
			repeat_times_ = 0;
			repeated_times_ = 0;

			set_cancel();
			next_op_stamp();

			BOOST_ASSERT(is_idle());
		}
 virtual void cleanup() {
     set_cancel(false);
 }
Beispiel #7
0
void reslimit::inc_cancel() {
    #pragma omp critical (reslimit_cancel)
    {        
        set_cancel(m_cancel+1);
    }
}
Beispiel #8
0
void reslimit::reset_cancel() {
    #pragma omp critical (reslimit_cancel)
    {
        set_cancel(0);
    }
}
int main (int argc, char **argv)
{
	
	ArvCamera * camera;
	ArvStream *stream;
	ArvBuffer *buffer;
	GOptionContext *context;
	GError *error = NULL;
	char memory_buffer[100000];
	int i;

	arv_g_thread_init (NULL);
	arv_g_type_init ();

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, arv_option_entries, NULL);

	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_option_context_free (context);
		g_print ("Option parsing failed: %s\n", error->message);
		g_error_free (error);
		return EXIT_FAILURE;
	}

	g_option_context_free (context);
	if (arv_option_max_frames < 0)
		arv_option_max_errors_before_abort = -1;
	
	save_buffer_fn = GetSaveBufferFn(arv_option_save_type);

	arv_debug_enable (arv_option_debug_domains);

	if (arv_option_camera_name == NULL)
		g_print ("Looking for the first available camera\n");
	else
		g_print ("Looking for camera '%s'\n", arv_option_camera_name);

	camera = arv_camera_new (arv_option_camera_name);
	
	int errors = 0;
	if (camera == NULL)
	{
		g_print("No device found");
		return 1;
	}

	guint payload_size = arv_camera_get_payload(camera);
	g_print ("payload size  = %d (0x%x)\n", payload_size, payload_size);
	

	stream = arv_camera_create_stream (camera, NULL, NULL);
	if (arv_option_auto_buffer)
	{
		g_object_set (stream,"socket-buffer", ARV_GV_STREAM_SOCKET_BUFFER_AUTO,"socket-buffer-size", 0,NULL);
	}
	
	for (i = 0; i < 30; i++)
	{
		arv_stream_push_buffer (stream, arv_buffer_new (payload_size, NULL));
	}
	
	arv_camera_stop_acquisition(camera);

	// set the bit depth
	ArvDevice * device = arv_camera_get_device(camera);
	ArvGcNode * feature = arv_device_get_feature(device, "PixelFormat");
	char * pix_format = "Mono8";
	if (arv_option_pixel_format == 14)
		pix_format = "Mono14";
	arv_gc_feature_node_set_value_from_string(ARV_GC_FEATURE_NODE(feature), pix_format, NULL);
	if (arv_option_pixel_format == 14)
	{
		feature = arv_device_get_feature(device, "CMOSBitDepth");
		arv_gc_feature_node_set_value_from_string(ARV_GC_FEATURE_NODE(feature), "bit14bit", NULL);
	}


	signal (SIGINT, set_cancel);
	signal (SIGQUIT, set_cancel);

	int captured_frames = 0;
	guint64 timeout=1000000;
	#define _CAN_STOP (arv_option_max_frames > 0 && captured_frames >= arv_option_max_frames)
	arv_camera_start_acquisition(camera);
	do {
		g_usleep (100000);
			do  {
			buffer = arv_stream_timeout_pop_buffer (stream, timeout);
			if (buffer == NULL) break;
			ArvBufferStatus status = arv_buffer_get_status(buffer);
			fprintf(stderr, "Status is %d\n", status);
			if (status == ARV_BUFFER_STATUS_SUCCESS)
			{
		
				
				
				if (timeout > 100000) timeout -= 1000;
				errors = 0;
				if (save_buffer_fn != NULL)
				{
					struct timespec timestamp;
					clock_gettime(CLOCK_REALTIME, &timestamp);
					char filename[BUFSIZ];
					if (strcmp(arv_option_save_prefix,"") != 0)
					{
						sprintf(filename, "%s/%s%d.%s", arv_option_save_dir,arv_option_save_prefix, captured_frames, arv_option_save_type);
					}
					else
					{
						sprintf(filename, "%s/%d.%03ld.%s", arv_option_save_dir, (int)timestamp.tv_sec, (long)(timestamp.tv_nsec/1.0e6), arv_option_save_type);
					}
					if ((*save_buffer_fn)(buffer, filename) == false)
					{
						g_print("Couldn't save frame %d to %s\n", captured_frames, filename);
						set_cancel(SIGQUIT);
					}
					g_print("Saved frame %d to %s\n", captured_frames, filename);
					char latest[] = "latest.png";
					sprintf(latest, "latest.%s", arv_option_save_type);
					unlink(latest);
					symlink(filename, latest);
				}
				captured_frames++;
				g_usleep(arv_option_sample_period);
			}
			else 
			{
				if (timeout < 10000000) timeout+=1000;
				fprintf(stderr, "%d errors out of %d allowed\n", errors, arv_option_max_errors_before_abort);
				arv_camera_stop_acquisition(camera);
				if (++errors > arv_option_max_errors_before_abort && arv_option_max_errors_before_abort >= 0)
				{
					set_cancel(SIGQUIT);
				}
				else
				{
					arv_camera_start_acquisition(camera);
				}
			}
			arv_stream_push_buffer (stream, buffer);
			
			
			
		} while (!cancel && buffer != NULL && !_CAN_STOP);
	} while (!cancel && !_CAN_STOP);
	arv_camera_stop_acquisition(camera);


	guint64 n_processed_buffers; guint64 n_failures; guint64 n_underruns;
	arv_stream_get_statistics (stream, &n_processed_buffers, &n_failures, &n_underruns);
	g_print ("Processed buffers = %Lu\n", (unsigned long long) n_processed_buffers);
	g_print ("Failures          = %Lu\n", (unsigned long long) n_failures);
	g_print ("Underruns         = %Lu\n", (unsigned long long) n_underruns);


	g_object_unref (stream);
	g_object_unref (camera);
	
	
	return (errors > 0);
}
Beispiel #10
0
void tactic::reset_cancel() {
    #pragma omp critical (tactic_cancel)
    {
        set_cancel(false);
    }
}
Beispiel #11
0
void tactic::cancel() {
    #pragma omp critical (tactic_cancel)
    {
        set_cancel(true);
    }
}
 void reset_cancel() { set_cancel(false); }        
 void cancel() { set_cancel(true); }