Example #1
0
// start_routine for thread A
void* threadA_routine (void *args) {

	// local variable
	char buf[BUFFER_SIZE];
	int rc;

	ThreadData_t * this_data = (ThreadData_t *)args;

	for (;;) {
	// block until pipe write semaphore reached
	sem_wait(this_data->pipeWrite_sem);

	printf("......................................\n");
	// read a line from data.txt
	// if eof reached, then thread A B C will stop
	rc = read_line(this_data->fp0, buf);
	if ((rc == 0) && (eof_reached == 1))
		terminateAll();

	// create a pipe 
	pipe_create(this_data->pipefd);

	// write the line to pipe
	pipe_in(this_data->pipefd, buf);

	printf("thread A completed\n");

	// post the pipe read signal
	sem_post(this_data->pipeRead_sem);

	}

}
Example #2
0
AsyncJobRouter::~AsyncJobRouter() {
    logger.debug("Async job router terminating");
    //Clean up everything
    terminateAll();
    doScrubJob();
    //Sockets are cleaned up in AbstractFrameProcessor
}
Example #3
0
void SessionsBox::Inner::onTerminateAll() {
	if (_terminateBox) _terminateBox->deleteLater();
	_terminateBox = Ui::show(Box<ConfirmBox>(lang(lng_settings_reset_sure), lang(lng_settings_reset_button), st::attentionBoxButton, base::lambda_guarded(this, [this] {
		if (_terminateBox) {
			_terminateBox->closeBox();
			_terminateBox = nullptr;
		}
		MTP::send(MTPauth_ResetAuthorizations(), rpcDone(&Inner::terminateAllDone), rpcFail(&Inner::terminateAllFail));
		emit terminateAll();
	})), LayerOption::KeepOther);
}
void terminateDevice(string device){
	ProtoMessage msg;
	msg.set_signal(ProtoMessage::TERMINATE);
	msg.set_dest_device(device);
	if (device == self) {
		terminateAll(0);
		sendProtobufMessage(name2socket["pod"],msg);
	} else{
		sendProtobufMessage(name2acceptor[device],msg);
		cout <<"Stopping " <<device <<endl;
		device2Thread[device].join();
		cout<<device <<" Stopped"<<endl;
	}
}
Example #5
0
void SessionsBox::prepare() {
	setTitle(langFactory(lng_sessions_other_header));

	addButton(langFactory(lng_close), [this] { closeBox(); });

	setDimensions(st::boxWideWidth, st::sessionsHeight);

	connect(_inner, SIGNAL(oneTerminated()), this, SLOT(onOneTerminated()));
	connect(_inner, SIGNAL(allTerminated()), this, SLOT(onAllTerminated()));
	connect(_inner, SIGNAL(terminateAll()), this, SLOT(onTerminateAll()));
	connect(App::wnd(), SIGNAL(checkNewAuthorization()), this, SLOT(onCheckNewAuthorization()));
	connect(_shortPollTimer, SIGNAL(timeout()), this, SLOT(onShortPollAuthorizations()));

	_inner = setInnerWidget(object_ptr<Inner>(this, &_list, &_current), st::sessionsScroll);
	_inner->resize(width(), st::noContactsHeight);

	setLoading(true);

	MTP::send(MTPaccount_GetAuthorizations(), rpcDone(&SessionsBox::gotAuthorizations));
}