Skip to content
Snippets Groups Projects
Commit 5c23b0c8 authored by Nicolas Leclercq's avatar Nicolas Leclercq
Browse files

release 1.7.17

parent 6a0357b7
No related branches found
No related tags found
No related merge requests found
......@@ -93,7 +93,7 @@ MyClass::Allocator * MyClass::cache = 0;
int main(int argc, char* argv[])
{
size_t nb = 10;
size_t bs = 1000000;
size_t bs = 1000;
size_t tt = nb * bs;
yat::Timer t;
......@@ -108,6 +108,7 @@ int main(int argc, char* argv[])
<< std::endl;
t.restart();
#endif
MyClass::init(nb, bs);
......
#==============================================================================
# Makefile to generate the YAT Test - NL - SOLEIL
#==============================================================================
#==============================================================================
# INCLUDE DIRS
#==============================================================================
INCLUDE_DIRS = -I. -I../../include
#==============================================================================
# LIB DIRS
#==============================================================================
LIB_DIRS = -L../../target/nar/lib/i386-Linux-g++/static
LIB_DIRS += -L../../src/.libs
#==============================================================================
# SRC FILE NAME
#===============================================================================
SRC = ./src/main.o ./src/my_task.o
#==============================================================================
# BINARY NAME
#===============================================================================
BIN = tasktest
#==============================================================================
# COMP$(CC)ILER/LINKER OPTIONS for GNU/LINUX
#==============================================================================
CC=g++
#------------------------------------------------------------------------------
CFLAGS = -pipe -O2 -W -g
#------------------------------------------------------------------------------
LD=gcc
#------------------------------------------------------------------------------
LDFLAGS =
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# LIBS
#------------------------------------------------------------------------------
LIBS = -lyat -lpthread -lstdc++ -ldl
#------------------------------------------------------------------------------
# OBJS FILES
#------------------------------------------------------------------------------
SRC_OBJS = $(SRC)
#------------------------------------------------------------------------------
# RULE for .cpp files
#------------------------------------------------------------------------------
.SUFFIXES: .o .cpp
.cpp.o:
$(CC) $(CFLAGS) $(INCLUDE_DIRS) -c -o $@ $<
#------------------------------------------------------------------------------
# RULE: all
#------------------------------------------------------------------------------
all: build
#------------------------------------------------------------------------------
# RULE: build
#------------------------------------------------------------------------------
build: $(SRC_OBJS)
$(LD) -o $(BIN) $(LDFLAGS) $(SRC_OBJS) $(LIB_DIRS) $(LIBS)
#------------------------------------------------------------------------------
# RULE: clean
#------------------------------------------------------------------------------
clean:
rm -f ./src/*.o
rm -f ./src/*~
rm -f ./$(BIN)
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>fr.soleil</groupId>
<artifactId>super-pom-C-CPP-device</artifactId>
<version>RELEASE</version>
</parent>
<groupId>fr.soleil.device</groupId>
<artifactId>yat-task-test-${aol}-${mode}</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>nar</packaging>
<name>TaskTester</name>
<description>a yat::Task test</description>
<build>
<plugins>
<plugin>
<groupId>org.freehep</groupId>
<artifactId>freehep-nar-plugin</artifactId>
<configuration>
<cpp>
<includePaths>
<includePath>${project.basedir}/src</includePath>
</includePaths>
<options>
<option>-Wno-uninitialized</option>
<option>-Wno-unused-parameter</option>
<option>-Wno-unused-variable</option>
</options>
</cpp>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<connection>${scm.connection.svn.tango-cs}:share/yat</connection>
<developerConnection>${scm.developerConnection.svn.tango-cs}:share/yat</developerConnection>
<url>${scm.url.svn.tango-cs}/share/yat</url>
</scm>
<dependencies>
<dependency>
<groupId>fr.soleil.lib</groupId>
<artifactId>YAT-${aol}-${library}-${mode}</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
<developers>
<developer>
<id>leclercq</id>
<name>leclercq</name>
<url>http://controle/</url>
<organization>Synchrotron Soleil</organization>
<organizationUrl>http://www.synchrotron-soleil.fr</organizationUrl>
<roles>
<role>manager</role>
</roles>
<timezone>1</timezone>
</developer>
</developers>
</project>
/*!
* \file
* \brief An example of yat::Task (and related classes) usage.
* \author N. Leclercq, J. Malik - Synchrotron SOLEIL
*/
#include <yat/time/Timer.h>
#include "my_task.h"
// ============================================================================
// play with the <lo> and <hi> msgQ watermarks to test the yat::msgQ in action
// ============================================================================
#define kLO_WATER_MARK 128
#define kHI_WATER_MARK 512
// ============================================================================
// play with the post msg timeout to test the associated yat::msgQ feature
// ============================================================================
#define kPOST_MSG_TMO 2
// ============================================================================
// number of messages to be posted in this example
// ============================================================================
#define kNUM_MSGS 8192
// ============================================================================
// main
// ============================================================================
int main(int argc, char* argv[])
{
yat::Message * m = 0;
YAT_LOG_STATIC("Instanciating Task...");
Consumer * dt = new Consumer(kLO_WATER_MARK, kHI_WATER_MARK);
YAT_LOG_STATIC("Starting Task...");
try
{
dt->go(2000);
}
catch (const yat::Exception&)
{
YAT_LOG_STATIC("yat exception caught - could not start task. aborting...");
dt->exit();
return 0;
}
catch (...)
{
YAT_LOG_STATIC("unknown exception caught - could not start task. aborting...");
dt->exit();
return 0;
}
for (size_t i = 0; i < kNUM_MSGS; i++)
{
try
{
//- post msg to consumer
dt->post(new yat::Message(kDUMMY_MSG), kPOST_MSG_TMO);
//- simulate some time consuming activity
yat::ThreadingUtilities::sleep(0, 100000);
}
catch (const std::bad_alloc&)
{
YAT_LOG_STATIC("std::bad_alloc except. caught - could not post msg#" << i);
}
catch (const yat::Exception&)
{
YAT_LOG_STATIC("tango except. caught - could not post msg#" << i);
}
catch (...)
{
YAT_LOG_STATIC("unknown except. caught - could not post msg#" << i);
}
}
try
{
dt->exit();
}
catch (const yat::Exception&)
{
YAT_LOG_STATIC("tango except. caught - could stop task. aborting...");
}
catch (...)
{
YAT_LOG_STATIC("unknown except. caught - could stop task. aborting...");
return 0;
}
return 0;
}
//- THIS IS JUST A TEST CODE BACKUP FOR A WORK IN PROGRESS
#ifdef _USE_MSG_CACHE_ //- (see yat/CommonHeader.h)
std::vector<yat::Message *> msgs(kNUM_MSGS);
yat::Timer t;
for (size_t i = 0; i < msgs.size(); i++)
msgs[i] = new yat::Message(kDUMMY_MSG);
double dt_usec = t.elapsed_usec();
std::cout << "First alloc took "
<< dt_usec
<< " usecs ["
<< dt_usec / kNUM_MSGS
<< " usecs per msg]"
<< std::endl;
for (size_t i = 0; i < msgs.size(); i++)
msgs[i]->release();
t.restart();
for (size_t i = 0; i < msgs.size(); i++)
msgs[i] = new yat::Message(kDUMMY_MSG);
dt_usec = t.elapsed_usec();
std::cout << "Second alloc took "
<< dt_usec
<< " usecs ["
<< dt_usec / kNUM_MSGS
<< " usecs per msg]"
<< std::endl;
for (size_t i = 0; i < msgs.size(); i++)
msgs[i]->release();
return 0;
#endif //- _USE_MSG_CACHE_
//- THIS IS JUST A TEST CODE BACKUP FOR THE MESSAGE DATA ALLOC OPTIMISATION
#ifdef _MESSAGE_DATA_OPTIMISATION_
double d = 1.2345;
double * dp = new double;
*dp = d;
long l= 12345;
long * lp = new long;
*lp = l;
m = new yat::Message(kDUMMY_MSG);
for (size_t i = 0; i < 10000; i++)
{
YAT_LOG_STATIC("********** 01 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 02 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 03 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 04 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 05 - Attaching T=long by addr. **********");
m->attach_data(&l, false);
YAT_LOG_STATIC("********** 06 - Attaching T=long by addr. **********");
m->attach_data(&l, false);
YAT_LOG_STATIC("********** 07 - Attaching T=double by addr. **********");
m->attach_data(&d, false);
YAT_LOG_STATIC("********** 08 - Attaching T=double by addr. **********");
m->attach_data(&d, false);
YAT_LOG_STATIC("********** 09 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 10 - Attaching T=double by addr. **********");
m->attach_data(dp,false);
YAT_LOG_STATIC("********** 11 - Attaching T=long by addr. **********");
m->attach_data(lp,false);
YAT_LOG_STATIC("********** 12 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 13 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 14 - Attaching T=long by addr. **********");
m->attach_data(lp, false);
YAT_LOG_STATIC("********** 15 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 16 - Attaching T=long by addr. **********");
m->attach_data(lp, false);
YAT_LOG_STATIC("********** 17 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 18 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 19 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 20 - Attaching T=double by addr. **********");
m->attach_data(dp, false);
YAT_LOG_STATIC("********** 21 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 22 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 23 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 24 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 25 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 26 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 27 - Attaching T=double by addr. **********");
m->attach_data(new double, true);
YAT_LOG_STATIC("********** 28 - Attaching T=long by addr. **********");
m->attach_data(new long, true);
YAT_LOG_STATIC("********** 29 - Attaching T=long by ref. **********");
m->attach_data(l);
YAT_LOG_STATIC("********** 30 - Attaching T=double by ref. **********");
m->attach_data(d);
YAT_LOG_STATIC("********** 31 - Attaching T=double by addr. **********");
m->attach_data(new double, false);
YAT_LOG_STATIC("********** 32 - Attaching T=double by addr. **********");
m->attach_data(new double, true);
YAT_LOG_STATIC("********** 33 - Attaching T=long by ref. **********");
m->attach_data(l);
}
m->release();
return 0;
#endif //- _MESSAGE_DATA_OPTIMISATION_
\ No newline at end of file
/*!
* \file
* \brief An example of yat::Task (and related classes) usage. .
* \author N. Leclercq, J. Malik - Synchrotron SOLEIL
*/
// ============================================================================
// DEPENDENCIES
// ============================================================================
#include "my_task.h"
// ============================================================================
// Consumer::Consumer
// ============================================================================
Consumer::Consumer (size_t _lo_wm, size_t _hi_wm)
: yat::Task(Config(true, //- enable timeout msg
1000, //- every second (i.e. 1000 msecs)
false, //- disable periodic msgs
0, //- no exec period for periodic msgs (disabled)
false, //- don't lock the internal mutex while handling a msg (recommended setting)
_lo_wm, //- msgQ low watermark value
_hi_wm, //- msgQ high watermark value
false, //- do not throw exception on post msg timeout (msqQ saturated)
0)), //- user data (same for all msgs) - we don't use it here
ctrl_msg_counter (0),
user_msg_counter (0)
#if defined (YAT_DEBUG)
, last_msg_id (0)
, lost_msg_counter (0)
, wrong_order_msg_counter (0)
#endif
{
YAT_TRACE("Consumer::Consumer");
}
// ======================================================================
// Consumer::~Consumer
// ======================================================================
Consumer::~Consumer (void)
{
YAT_TRACE("Consumer::~Consumer");
#if defined (YAT_DEBUG)
YAT_LOG("Consumer::statistics::ctrl msg:: " << this->ctrl_msg_counter);
YAT_LOG("Consumer::statistics::user msg:: " << this->user_msg_counter);
YAT_LOG("Consumer::statistics::lost msg:: " << this->lost_msg_counter);
YAT_LOG("Consumer::statistics::wrong order msg:: " << this->wrong_order_msg_counter);
#endif
}
// ============================================================================
// Consumer::handle_message
// ============================================================================
void Consumer::handle_message (yat::Message& _msg)
throw (yat::Exception)
{
//- YAT_TRACE("Consumer::handle_message");
//- handle msg
switch (_msg.type())
{
//- TASK_INIT ----------------------
case yat::TASK_INIT:
{
//- "initialization" code goes here
YAT_LOG("Consumer::handle_message::TASK_INIT::task is starting up");
this->ctrl_msg_counter++;
}
break;
//- TASK_EXIT ----------------------
case yat::TASK_EXIT:
{
//- "release" code goes here
YAT_LOG("Consumer::handle_message::TASK_EXIT::task is quitting");
this->ctrl_msg_counter++;
}
break;
//- TASK_PERIODIC ------------------
case yat::TASK_PERIODIC:
{
//- code relative to the task's periodic job goes here
YAT_LOG("Consumer::handle_message::handling TASK_PERIODIC msg");
}
break;
//- TASK_TIMEOUT -------------------
case yat::TASK_TIMEOUT:
{
//- code relative to the task's tmo handling goes here
YAT_LOG("Consumer::handle_message::handling TASK_TIMEOUT msg");
}
break;
//- USER_DEFINED_MSG -----------------
case kDUMMY_MSG:
{
//- YAT_LOG("Consumer::handle_message::handling kDUMMY_MSG user msg");
this->user_msg_counter++;
#if defined (YAT_DEBUG)
if (_msg.id() < last_msg_id)
this->wrong_order_msg_counter++;
else
this->lost_msg_counter += _msg.id() - (this->last_msg_id + 1);
#endif
//- simulate some time consuming activity
yat::ThreadingUtilities::sleep(0, 10000);
}
break;
default:
YAT_LOG("Consumer::handle_message::unhandled msg type received");
break;
}
#if defined (YAT_DEBUG)
this->last_msg_id = _msg.id();
#endif
}
/*!
* \file
* \brief An example of yat::Task (and related classes) usage. .
* \author N. Leclercq, J. Malik - Synchrotron SOLEIL
*/
#ifndef _MY_TASK_H_
#define _MY_TASK_H_
// ============================================================================
// DEPENDENCIES
// ============================================================================
#include <iostream>
#include <yat/threading/Task.h>
// ============================================================================
// SOME USER DEFINED MESSAGES
// ============================================================================
#define kDUMMY_MSG (yat::FIRST_USER_MSG + 1000)
// ============================================================================
// SOME USER DEFINED MESSAGE PRIORITIES
// ============================================================================
#define kDUMMY_MSG_PRIORITY adtb::MAX_USER_PRIORITY
// ============================================================================
// class: Consumer
// ============================================================================
class Consumer: public yat::Task
{
public:
//- ctor ---------------------------------
Consumer (size_t lo_wm, size_t hi_wm);
//- dtor ---------------------------------
virtual ~Consumer (void);
protected:
//- handle_message -----------------------
virtual void handle_message (yat::Message& msg)
throw (yat::Exception);
private:
//- num of ctrl msg received
unsigned long ctrl_msg_counter;
//- num of user msg received
unsigned long user_msg_counter;
#if defined (YAT_DEBUG)
//- id of the last received msg
yat::Message::MessageID last_msg_id;
//- num of lost msg
unsigned long lost_msg_counter;
//- num msg received in wrong order
unsigned long wrong_order_msg_counter;
#endif
};
#endif // _MY_TASK_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment