Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.hfa

    r3e2b9c9 r47746a2  
    1616#pragma once
    1717
     18#include <stdbool.h>
     19#include <stdint.h>
     20
    1821#include "invoke.h"
    1922#include "time_t.hfa"
     
    2326
    2427extern "C" {
    25 #include <bits/pthreadtypes.h>
     28#include <pthread.h>
     29#include <semaphore.h>
    2630}
    2731
     
    125129struct __io_data;
    126130
    127 // IO poller user-thread
    128 // Not using the "thread" keyword because we want to control
    129 // more carefully when to start/stop it
    130 struct $io_ctx_thread {
    131         struct __io_data * ring;
    132         single_sem sem;
    133         volatile bool done;
    134         $thread self;
    135 };
    136 
    137 
    138 struct io_context {
    139         $io_ctx_thread thrd;
    140 };
    141 
    142 struct io_context_params {
    143         int num_entries;
    144         int num_ready;
    145         int submit_aff;
    146         bool eager_submits:1;
    147         bool poller_submits:1;
    148         bool poll_submit:1;
    149         bool poll_complete:1;
    150 };
    151 
    152 void  ?{}(io_context_params & this);
    153 
    154 void  ?{}(io_context & this, struct cluster & cl);
    155 void  ?{}(io_context & this, struct cluster & cl, const io_context_params & params);
    156 void ^?{}(io_context & this);
    157 
    158 struct io_cancellation {
    159         uint32_t target;
    160 };
    161 
    162 static inline void  ?{}(io_cancellation & this) { this.target = -1u; }
    163 static inline void ^?{}(io_cancellation & this) {}
    164 bool cancel(io_cancellation & this);
     131#define CFA_CLUSTER_IO_POLLER_USER_THREAD    (1 << 0) // 0x01
     132#define CFA_CLUSTER_IO_POLLER_THREAD_SUBMITS (1 << 1) // 0x02
     133#define CFA_CLUSTER_IO_EAGER_SUBMITS         (1 << 2) // 0x04
     134#define CFA_CLUSTER_IO_KERNEL_POLL_SUBMITS   (1 << 3) // 0x08
     135#define CFA_CLUSTER_IO_KERNEL_POLL_COMPLETES (1 << 4) // 0x10
     136#define CFA_CLUSTER_IO_BUFFLEN_OFFSET        16
     137
    165138
    166139//-----------------------------------------------------------------------------
     
    233206        } node;
    234207
    235         struct {
    236                 io_context * ctxs;
    237                 unsigned cnt;
    238         } io;
     208        struct __io_data * io;
    239209
    240210        #if !defined(__CFA_NO_STATISTICS__)
     
    245215extern Duration default_preemption();
    246216
    247 void ?{} (cluster & this, const char name[], Duration preemption_rate, unsigned num_io, const io_context_params & io_params);
     217void ?{} (cluster & this, const char name[], Duration preemption_rate, unsigned flags);
    248218void ^?{}(cluster & this);
    249219
    250 static inline void ?{} (cluster & this)                                            { io_context_params default_params;    this{"Anonymous Cluster", default_preemption(), 1, default_params}; }
    251 static inline void ?{} (cluster & this, Duration preemption_rate)                  { io_context_params default_params;    this{"Anonymous Cluster", preemption_rate, 1, default_params}; }
    252 static inline void ?{} (cluster & this, const char name[])                         { io_context_params default_params;    this{name, default_preemption(), 1, default_params}; }
    253 static inline void ?{} (cluster & this, unsigned num_io)                           { io_context_params default_params;    this{"Anonymous Cluster", default_preemption(), num_io, default_params}; }
    254 static inline void ?{} (cluster & this, Duration preemption_rate, unsigned num_io) { io_context_params default_params;    this{"Anonymous Cluster", preemption_rate, num_io, default_params}; }
    255 static inline void ?{} (cluster & this, const char name[], unsigned num_io)        { io_context_params default_params;    this{name, default_preemption(), num_io, default_params}; }
    256 static inline void ?{} (cluster & this, const io_context_params & io_params)                                            { this{"Anonymous Cluster", default_preemption(), 1, io_params}; }
    257 static inline void ?{} (cluster & this, Duration preemption_rate, const io_context_params & io_params)                  { this{"Anonymous Cluster", preemption_rate, 1, io_params}; }
    258 static inline void ?{} (cluster & this, const char name[], const io_context_params & io_params)                         { this{name, default_preemption(), 1, io_params}; }
    259 static inline void ?{} (cluster & this, unsigned num_io, const io_context_params & io_params)                           { this{"Anonymous Cluster", default_preemption(), num_io, io_params}; }
    260 static inline void ?{} (cluster & this, Duration preemption_rate, unsigned num_io, const io_context_params & io_params) { this{"Anonymous Cluster", preemption_rate, num_io, io_params}; }
    261 static inline void ?{} (cluster & this, const char name[], unsigned num_io, const io_context_params & io_params)        { this{name, default_preemption(), num_io, io_params}; }
     220static inline void ?{} (cluster & this)                                           { this{"Anonymous Cluster", default_preemption(), 0}; }
     221static inline void ?{} (cluster & this, Duration preemption_rate)                 { this{"Anonymous Cluster", preemption_rate, 0}; }
     222static inline void ?{} (cluster & this, const char name[])                        { this{name, default_preemption(), 0}; }
     223static inline void ?{} (cluster & this, unsigned flags)                           { this{"Anonymous Cluster", default_preemption(), flags}; }
     224static inline void ?{} (cluster & this, Duration preemption_rate, unsigned flags) { this{"Anonymous Cluster", preemption_rate, flags}; }
     225static inline void ?{} (cluster & this, const char name[], unsigned flags)        { this{name, default_preemption(), flags}; }
    262226
    263227static inline [cluster *&, cluster *& ] __get( cluster & this ) __attribute__((const)) { return this.node.[next, prev]; }
Note: See TracChangeset for help on using the changeset viewer.