Commit 62ef23a9 authored by Dominik Charousset's avatar Dominik Charousset

removed obsolete files

parent 10d12202
This diff is collapsed.
ACLOCAL_AMFLAGS = -I ../m4
bin_PROGRAMS = cppatest
cppatest_SOURCES = \
../src/abstract_tuple.cpp \
../src/abstract_type_list.cpp \
../src/actor_behavior.cpp \
../src/actor_count.cpp \
../src/actor.cpp \
../src/actor_proxy_cache.cpp \
../src/actor_proxy.cpp \
../src/actor_registry.cpp \
../src/addressed_message.cpp \
../src/any_tuple.cpp \
../src/any_tuple_iterator.cpp \
../src/atom.cpp \
../src/attachable.cpp \
../src/binary_deserializer.cpp \
../src/binary_serializer.cpp \
../src/blocking_message_queue.cpp \
../src/channel.cpp \
../src/local_actor.cpp \
../src/converted_thread_context.cpp \
../src/cppa.cpp \
../src/delegate.cpp \
../src/demangle.cpp \
../src/deserializer.cpp \
../src/duration.cpp \
../src/empty_tuple.cpp \
../src/exception.cpp \
../src/fiber.cpp \
../src/group.cpp \
../src/group_manager.cpp \
../src/intermediate.cpp \
../src/invokable.cpp \
../src/invoke_rules.cpp \
../src/mailman.cpp \
../src/matcher_arguments.cpp \
../src/message_queue.cpp \
../src/mock_scheduler.cpp \
../src/native_socket.cpp \
../src/network_manager.cpp \
../src/object_array.cpp \
../src/object.cpp \
../src/post_office.cpp \
../src/post_office_msg.cpp \
../src/primitive_variant.cpp \
../src/process_information.cpp \
../src/ripemd_160.cpp \
../src/scheduled_actor.cpp \
../src/scheduler.cpp \
../src/serializer.cpp \
../src/shared_spinlock.cpp \
../src/singleton_manager.cpp \
../src/string_serialization.cpp \
../src/task_scheduler.cpp \
../src/thread_pool_scheduler.cpp \
../src/to_uniform_name.cpp \
../src/unicast_network.cpp \
../src/uniform_type_info.cpp \
../src/yielding_message_queue.cpp \
../src/yield_interface.cpp \
../unit_testing/hash_of.cpp \
../unit_testing/main.cpp \
../unit_testing/ping_pong.cpp \
../unit_testing/test__a_matches_b.cpp \
../unit_testing/test__atom.cpp \
../unit_testing/test__intrusive_ptr.cpp \
../unit_testing/test__local_group.cpp \
../unit_testing/test__primitive_variant.cpp \
../unit_testing/test__remote_actor.cpp \
../unit_testing/test__ripemd_160.cpp \
../unit_testing/test__serialization.cpp \
../unit_testing/test__spawn.cpp \
../unit_testing/test__tuple.cpp \
../unit_testing/test__type_list.cpp \
../unit_testing/test__uniform_type.cpp \
../unit_testing/test__yield_interface.cpp
AM_CPPFLAGS = -I../
cppatest_CXXFLAGS = --std=c++0x -pedantic -Wall -Wextra
#AM_LDFLAGS = $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
cppatest_LDADD = $(BOOST_LDFLAGS) $(BOOST_THREAD_LIB)
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <stdio.h>
#include <ucontext.h>
#include <sys/mman.h>
#include <signal.h>
#include <stddef.h>
static ucontext_t ctx[2];
__thread int m_count = 0;
void coroutine()
{
for (;;)
{
++m_count;
printf("m_count = %i\n", m_count);
swapcontext(&ctx[1], &ctx[0]);
}
}
int main(int argc, char** argv)
{
int i;
void* coroutine_stack = mmap(0,
SIGSTKSZ,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON,
-1,
0);
memset(&ctx[0], 0, sizeof(ucontext_t));
getcontext(&ctx[0]);
memset(&ctx[1], 0, sizeof(ucontext_t));
getcontext(&ctx[1]);
ctx[1].uc_stack.ss_sp = coroutine_stack;
ctx[1].uc_stack.ss_size = SIGSTKSZ;
ctx[1].uc_link = &ctx[0];
makecontext(&ctx[1], coroutine, 0);
for (i = 1; i < 11; ++i)
{
printf("i = %i\n", i);
swapcontext(&ctx[0], &ctx[1]);
}
munmap(coroutine_stack, SIGSTKSZ);
return 0;
}
AC_PREREQ([2.6])
AC_INIT([cppatest], [0.1])
AM_INIT_AUTOMAKE(@PACKAGE_NAME@, @PACKAGE_VERSION@)
AC_CONFIG_MACRO_DIR([../m4])
AC_PROG_CXX
# check for boost and boost_thread
AX_BOOST_BASE([1.42.0])
AX_BOOST_THREAD
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
#include <iostream>
#include "cppa_fibre.h"
using std::cout;
using std::endl;
struct pseudo_worker {
int m_value;
pseudo_worker() : m_value(0) { }
void operator()() {
for (;;) {
++m_value;
cout << "value = " << m_value << endl;
cppa_fibre_yield(0);
}
}
};
void coroutine() {
auto pw = reinterpret_cast<pseudo_worker*>(cppa_fibre_init_switch_arg()); (*pw)();
}
int main() {
pseudo_worker pw;
cppa_fibre fself;
cppa_fibre fcoroutine;
cppa_fibre_ctor(&fself);
cppa_fibre_ctor2(&fcoroutine, coroutine, &pw);
cppa_fibre_initialize(&fcoroutine);
for (int i = 1; i < 11; ++i) {
cout << "i = " << i << endl;
cppa_fibre_switch(&fself, &fcoroutine);
}
cppa_fibre_dtor(&fself);
cppa_fibre_dtor(&fcoroutine);
return 0;
}
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <ucontext.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <signal.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include "cppa_fibre.h"
__thread void* s_switch_arg;
__thread int s_yield_value;
__thread ucontext_t* s_caller;
__thread ucontext_t* s_callee;
void cppa_fibre_ctor(cppa_fibre* instance)
{
instance->m_state = 0;
memset(&(instance->m_context), 0, sizeof(ucontext_t));
getcontext(&(instance->m_context));
instance->m_fun = 0;
instance->m_init_arg = 0;
}
void cppa_fibre_ctor2(cppa_fibre* instance, void (*fun)(), void* arg)
{
cppa_fibre_ctor(instance);
instance->m_state = 1;
instance->m_fun = fun;
instance->m_init_arg = arg;
}
void cppa_fibre_initialize(cppa_fibre* instance)
{
if (instance->m_state == 1)
{
instance->m_state = 2;
instance->m_context.uc_stack.ss_sp = mmap(0,
SIGSTKSZ,
PROT_EXEC | PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON,
-1,
0);
instance->m_context.uc_stack.ss_size = SIGSTKSZ;
makecontext(&(instance->m_context), instance->m_fun, 0);
s_switch_arg = instance->m_init_arg;
}
}
void cppa_fibre_dtor(cppa_fibre* instance)
{
if (instance->m_state == 2)
{
munmap(instance->m_context.uc_stack.ss_sp, SIGSTKSZ);
}
}
void* cppa_fibre_init_switch_arg()
{
return s_switch_arg;
}
void cppa_fibre_switch(cppa_fibre* from, cppa_fibre* to)
{
ucontext_t* ctx_from = &(from->m_context);
ucontext_t* ctx_to = &(to->m_context);
s_caller = ctx_from;
s_callee = ctx_to;
swapcontext(ctx_from, ctx_to);
}
void cppa_fibre_yield(int value)
{
s_yield_value = value;
swapcontext(s_callee, s_caller);
}
int cppa_fibre_yielded_value()
{
return s_yield_value;
}
#ifndef CPPA_FIBRE_H
#define CPPA_FIBRE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE
#endif
#include <stdio.h>
#include <ucontext.h>
struct cppa_fibre_struct
{
// 0: *this* context
// 1: fibre with function to execute, no stack assigned yet
// 2: as 1 but with assigned stack
int m_state;
ucontext_t m_context;
void (*m_fun)();
void* m_init_arg;
};
typedef struct cppa_fibre_struct cppa_fibre;
void cppa_fibre_ctor(cppa_fibre* instance);
/*
* @brief Initializes the given fibre.
* @param instance Pointer to an uninitialized object.
* @param fun Function this fibre should execute.
* @param switch_arg This pointer is stored in a
* thread-local variable on first
* context switch to @p instance.
*/
void cppa_fibre_ctor2(cppa_fibre* instance,
void (*fun)(),
void* switch_arg);
/*
* @warning call directly before the first switch
*/
void cppa_fibre_initialize(cppa_fibre* instance);
void cppa_fibre_dtor(cppa_fibre* instance);
/*
* @brief Returns
*/
void* cppa_fibre_init_switch_arg();
void cppa_fibre_switch(cppa_fibre* from, cppa_fibre* to);
/*
* Switches back to the calling fibre.
*/
void cppa_fibre_yield(int value);
/*
* Gets the yielded value of the client fibre.
*/
int cppa_fibre_yielded_value();
#ifdef __cplusplus
}
#endif
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment