Changeset e15df4c for src/libcfa


Ignore:
Timestamp:
Jan 24, 2017, 4:50:45 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
ad56482
Parents:
2cdf6dc
Message:

Renamed thread to scoped and thread_h to thread

Location:
src/libcfa/concurrency
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/invoke.c

    r2cdf6dc re15df4c  
    2929
    3030extern void __suspend_no_inline__F___1(void);
    31 extern void __signal_termination__F_P9sthread_h__1(struct thread_h*);
     31extern void __signal_termination__F_P9sthread_h__1(struct thread*);
    3232
    3333void CtxInvokeCoroutine(
     
    5858void CtxInvokeThread(
    5959      void (*main)(void *),
    60       struct thread_h *(*get_thread)(void *),
     60      struct thread *(*get_thread)(void *),
    6161      void *this
    6262) {
     
    6565      __suspend_no_inline__F___1();
    6666
    67       struct thread_h* thrd = get_thread( this );
     67      struct thread* thrd = get_thread( this );
    6868      struct coroutine* cor = &thrd->c;
    6969      cor->state = Active;
  • src/libcfa/concurrency/invoke.h

    r2cdf6dc re15df4c  
    3131
    3232      struct simple_thread_list {
    33             struct thread_h * head;
    34             struct thread_h ** tail;
     33            struct thread * head;
     34            struct thread ** tail;
    3535      };
    3636
     
    3838      extern "Cforall" {
    3939            void ?{}( struct simple_thread_list * );
    40             void append( struct simple_thread_list *, struct thread_h * );
    41             struct thread_h * pop_head( struct simple_thread_list * );
     40            void append( struct simple_thread_list *, struct thread * );
     41            struct thread * pop_head( struct simple_thread_list * );
    4242      }
    4343      #endif
     
    7070      };
    7171
    72       struct thread_h {
     72      struct thread {
    7373            struct coroutine c;
    7474            struct simple_lock lock;
    75             struct thread_h * next;
     75            struct thread * next;
    7676      };
    7777
  • src/libcfa/concurrency/kernel

    r2cdf6dc re15df4c  
    4242        cluster * cltr;
    4343        coroutine * current_coroutine;
    44         thread_h * current_thread;
     44        thread * current_thread;
    4545        pthread_t kernel_thread;
    4646        simple_lock lock;
  • src/libcfa/concurrency/kernel.c

    r2cdf6dc re15df4c  
    4646KERNEL_STORAGE(cluster, systemCluster);
    4747KERNEL_STORAGE(processor, systemProcessor);
    48 KERNEL_STORAGE(thread_h, mainThread);
     48KERNEL_STORAGE(thread, mainThread);
    4949KERNEL_STORAGE(machine_context_t, mainThread_context);
    5050
    5151cluster * systemCluster;
    5252processor * systemProcessor;
    53 thread_h * mainThread;
     53thread * mainThread;
    5454
    5555void kernel_startup(void)  __attribute__((constructor(101)));
     
    6969}
    7070
    71 thread_h * this_thread(void) {
     71thread * this_thread(void) {
    7272        return this_processor->current_thread;
    7373}
     
    117117}
    118118
    119 void ?{}( thread_h * this, current_stack_info_t * info) {
     119void ?{}( thread * this, current_stack_info_t * info) {
    120120        (&this->c){ info };
    121121}
     
    183183// Processor running routines
    184184void main(processorCtx_t * ctx);
    185 thread_h * nextThread(cluster * this);
    186 void runThread(processor * this, thread_h * dst);
     185thread * nextThread(cluster * this);
     186void runThread(processor * this, thread * dst);
    187187void spin(processor * this, unsigned int * spin_count);
    188188
     
    191191        LIB_DEBUG_PRINTF("Kernel : core %p starting\n", this);
    192192
    193         thread_h * readyThread = NULL;
     193        thread * readyThread = NULL;
    194194        for( unsigned int spin_count = 0; ! this->terminated; spin_count++ ) {
    195195               
     
    209209}
    210210
    211 void runThread(processor * this, thread_h * dst) {
     211void runThread(processor * this, thread * dst) {
    212212        coroutine * proc_ctx = get_coroutine(this->ctx);
    213213        coroutine * thrd_ctx = get_coroutine(dst);
     
    284284//-----------------------------------------------------------------------------
    285285// Scheduler routines
    286 void thread_schedule( thread_h * thrd ) {
     286void thread_schedule( thread * thrd ) {
    287287        assertf( thrd->next == NULL, "Expected null got %p", thrd->next );
    288288       
     
    291291}
    292292
    293 thread_h * nextThread(cluster * this) {
     293thread * nextThread(cluster * this) {
    294294        pthread_spinlock_guard guard = { &this->lock };
    295295        return pop_head( &this->ready_queue );
     
    314314
    315315        // Start by initializing the main thread
    316         mainThread = (thread_h *)&mainThread_storage;
     316        mainThread = (thread *)&mainThread_storage;
    317317        mainThread{ &info };
    318318
     
    391391
    392392void unlock( simple_lock * this ) {
    393         thread_h * it;
     393        thread * it;
    394394        while( it = pop_head( &this->blocked) ) {
    395395                thread_schedule( it );
     
    404404}
    405405
    406 void append( simple_thread_list * this, thread_h * t ) {
     406void append( simple_thread_list * this, thread * t ) {
    407407        assert( t->next == NULL );
    408408        *this->tail = t;
     
    410410}
    411411
    412 thread_h * pop_head( simple_thread_list * this ) {
    413         thread_h * head = this->head;
     412thread * pop_head( simple_thread_list * this ) {
     413        thread * head = this->head;
    414414        if( head ) {
    415415                this->head = head->next;
  • src/libcfa/concurrency/threads

    r2cdf6dc re15df4c  
    2929trait is_thread(dtype T | sized(T)) {
    3030      void main(T* this);
    31       thread_h* get_thread(T* this);
     31      thread* get_thread(T* this);
    3232};
    3333
    34 #define DECL_THREAD(X) static inline thread_h* get_thread(X* this) { return &this->t; } void main(X* this);
     34#define DECL_THREAD(X) static inline thread* get_thread(X* this) { return &this->t; } void main(X* this);
    3535
    3636forall( dtype T | sized(T) | is_thread(T) )
     
    3939}
    4040
    41 static inline coroutine* get_coroutine(thread_h* this) {
     41static inline coroutine* get_coroutine(thread* this) {
    4242        return &this->c;
    4343}
    4444
    45 thread_h * this_thread(void);
     45thread * this_thread(void);
    4646
    4747//-----------------------------------------------------------------------------
    4848// Ctors and dtors
    49 void ?{}(thread_h* this);
    50 void ^?{}(thread_h* this);
     49void ?{}(thread* this);
     50void ^?{}(thread* this);
    5151
    5252//-----------------------------------------------------------------------------
     
    5454// Structure that actually start and stop threads
    5555forall( dtype T | sized(T) | is_thread(T) )
    56 struct thread {
     56struct scoped {
    5757        T handle;
    5858};
    5959
    6060forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T*); } )
    61 void ?{}( thread(T)* this );
     61void ?{}( scoped(T)* this );
    6262
    6363forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T*, P); } )
    64 void ?{}( thread(T)* this, P params );
     64void ?{}( scoped(T)* this, P params );
    6565
    6666forall( dtype T | sized(T) | is_thread(T) | { void ^?{}(T*); } )
    67 void ^?{}( thread(T)* this );
     67void ^?{}( scoped(T)* this );
    6868
    6969void yield();
  • src/libcfa/concurrency/threads.c

    r2cdf6dc re15df4c  
    4040// Thread ctors and dtors
    4141
    42 void ?{}(thread_h* this) {
     42void ?{}(thread* this) {
    4343        (&this->c){};
    4444        this->c.name = "Anonymous Coroutine";
     
    4747}
    4848
    49 void ^?{}(thread_h* this) {
     49void ^?{}(thread* this) {
    5050        ^(&this->c){};
    5151}
    5252
    5353forall( dtype T | sized(T) | is_thread(T) | { void ?{}(T*); } )
    54 void ?{}( thread(T)* this ) {
     54void ?{}( scoped(T)* this ) {
    5555        (&this->handle){};
    5656        start(&this->handle);
     
    5858
    5959forall( dtype T, ttype P | sized(T) | is_thread(T) | { void ?{}(T*, P); } )
    60 void ?{}( thread(T)* this, P params ) {
     60void ?{}( scoped(T)* this, P params ) {
    6161        (&this->handle){ params };
    6262        start(&this->handle);
     
    6464
    6565forall( dtype T | sized(T) | is_thread(T) | { void ^?{}(T*); } )
    66 void ^?{}( thread(T)* this ) {
     66void ^?{}( scoped(T)* this ) {
    6767        stop(&this->handle);
    6868        ^(&this->handle){};
     
    7676}
    7777
    78 extern void thread_schedule( thread_h * );
     78extern void thread_schedule( thread * );
    7979
    8080forall( dtype T | sized(T) | is_thread(T) )
    8181void start( T* this ) {
    8282        coroutine* thrd_c = get_coroutine(this);
    83         thread_h*  thrd_h = get_thread   (this);
     83        thread*  thrd_h = get_thread   (this);
    8484        thrd_c->last = this_coroutine();
    8585        get_this_processor()->current_coroutine = thrd_c;
     
    9696forall( dtype T | sized(T) | is_thread(T) )
    9797void stop( T* this ) {
    98         thread_h*  thrd = get_thread(this);
     98        thread*  thrd = get_thread(this);
    9999        if( thrd->c.notHalted ) {
    100100                lock( &thrd->lock );
     
    102102}
    103103
    104 void signal_termination( thread_h * this ) {
     104void signal_termination( thread * this ) {
    105105        this->c.state = Halt;
    106106      this->c.notHalted = false;
Note: See TracChangeset for help on using the changeset viewer.