Ignore:
Timestamp:
Aug 8, 2006 11:56:49 PM (18 years ago)
Author:
ismangil
Message:

Work in progress, RThread still not compiling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/symbian/pjlib/src/pj/os_core_symbian.cpp

    r496 r666  
    1717 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
    1818 */ 
     19 
     20#include <e32std.h> 
    1921 
    2022#include <pj/os.h> 
     
    3638 
    3739 
     40struct pj_thread_t 
     41{ 
     42    char        obj_name[PJ_MAX_OBJ_NAME]; 
     43    RThread    thread; 
     44    pj_thread_proc *proc; 
     45    void           *arg; 
     46         
     47}; 
     48 
    3849/* 
    3950    TODO: implement these stub methods! 
     
    5061} 
    5162 
     63/* 
     64 * thread_main() 
     65 * 
     66 * This is the main entry for all threads. 
     67 */ 
     68TInt *thread_main(TAny *param) 
     69{ 
     70    pj_thread_t *rec = (pj_thread_t *) param; 
     71    TInt *result; 
     72    /* pj_status_t rc; */ 
     73 
     74    PJ_LOG(6,(rec->obj_name, "Thread started")); 
     75 
     76    /* Call user's entry! */ 
     77    result = (TInt*)(long)(*rec->proc)(rec->arg); 
     78 
     79    /* Done. */ 
     80    PJ_LOG(6,(rec->obj_name, "Thread quitting")); 
     81 
     82    return result; 
     83} 
     84 
     85/* 
     86 * pj_thread_create(...) 
     87 */ 
     88PJ_DEF(pj_status_t) pj_thread_create( pj_pool_t *pool,  
     89                                      const char *thread_name, 
     90                                      pj_thread_proc *proc,  
     91                                      void *arg, 
     92                                      pj_size_t stack_size,  
     93                                      unsigned flags, 
     94                                      pj_thread_t **ptr_thread) 
     95{ 
     96    pj_thread_t *rec; 
     97    int rc; 
     98 
     99 
     100    PJ_ASSERT_RETURN(pool && proc && ptr_thread, PJ_EINVAL); 
     101 
     102    /* Create thread record and assign name for the thread */ 
     103    rec = (struct pj_thread_t*) pj_pool_zalloc(pool, sizeof(pj_thread_t)); 
     104    PJ_ASSERT_RETURN(rec, PJ_ENOMEM); 
     105     
     106    /* Set name. */ 
     107    if (!thread_name)  
     108        thread_name = "thr%p"; 
     109     
     110    if (strchr(thread_name, '%')) { 
     111        pj_ansi_snprintf(rec->obj_name, PJ_MAX_OBJ_NAME, thread_name, rec); 
     112    } else { 
     113        strncpy(rec->obj_name, thread_name, PJ_MAX_OBJ_NAME); 
     114        rec->obj_name[PJ_MAX_OBJ_NAME-1] = '\0'; 
     115    } 
     116 
     117 
     118    /* Create the thread. */ 
     119    rec->proc = proc; 
     120    rec->arg = arg; 
     121    _LIT( KThreadName, "A name"); 
     122    rc = rec->thread.Create(KThreadName, thread_main, 4096, KMinHeapSize, 256*16, rec->arg, EOwnerProcess); 
     123    if (rc != 0) { 
     124        return PJ_RETURN_OS_ERROR(rc); 
     125    } 
     126 
     127    *ptr_thread = rec; 
     128 
     129    PJ_LOG(6, (rec->obj_name, "Thread created")); 
     130    return PJ_SUCCESS; 
     131} 
     132 
    52133/////////////////////////////////////////////////////////////////////////////// 
    53134/* 
     
    66147} 
    67148 
     149class foodata 
     150{ 
     151}; 
     152 
    68153/* 
    69154 * pj_thread_local_set() 
     
    79164PJ_DEF(void*) pj_thread_local_get(long index) 
    80165{ 
    81     return NULL; 
     166    return NULL; //Dll::Tls(); 
    82167} 
    83168 
Note: See TracChangeset for help on using the changeset viewer.