Branch: Tag:

2001-02-01

2001-02-01 19:59:30 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Moved some AutoDoc mk II markup to threads.c.

Rev: lib/modules/Thread.pmod:1.30

21: Inside #if constant(thread_create)
  optional constant _Disabled=__builtin.threads_disabled;   optional constant Local=__builtin.thread_local;    - //! @decl Thread.Thread Thread.Thread(function(mixed...:void) f, - //! mixed ... args) - //! - //! This function creates a new thread which will run simultaneously - //! to the rest of the program. The new thread will call the function - //! @[f] with the arguments @[args]. When @[f] returns the thread will cease - //! to exist. - //! - //! All Pike functions are 'thread safe' meaning that running - //! a function at the same time from different threads will not corrupt - //! any internal data in the Pike process. - //! - //! @returns - //! The returned value will be the same as the return value of - //! @[Thread.this_thread()] for the new thread. - //! - //! @note - //! This function is only available on systems with POSIX or UNIX or WIN32 - //! threads support. - //! - //! @seealso - //! @[Mutex], @[Condition], @[this_thread()] - //! +    optional constant thread_create = predef::thread_create;    - //! @decl Thread.Thread this_thread() - //! - //! This function returns the object that identifies this thread. - //! - //! @seealso - //! @[Thread.Thread()] - //! +    optional constant this_thread = predef::this_thread;    - //! @decl array(Thread.Thread) all_threads() - //! - //! This function returns an array with the thread ids of all threads. - //! - //! @seealso - //! @[Thread.Thread()] - //! +    optional constant all_threads = predef::all_threads;      
575:      // Simulations of some of the classes for nonthreaded use.    + /* Fallback implementation of Thread.Local */   class Local   {    static mixed data;
582:    mixed set (mixed val) {return data = val;}   }    + /* Fallback implementation of Thread.MutexKey */   class MutexKey (static function(:void) dec_locks)   {    int `!()
599:    }   }    - //! @[Thread.Mutex] is a class that implements mutual exclusion locks. - //! Mutex locks are used to prevent multiple threads from simultaneously - //! execute sections of code which access or change shared data. The basic - //! operations for a mutex is locking and unlocking. If a thread attempts - //! to lock an already locked mutex the thread will sleep until the mutex - //! is unlocked. - //! - //! @note - //! This class is simulated when Pike is compiled without thread support, - //! so it's always available. - //! - //! In POSIX threads, mutex locks can only be unlocked by the same thread - //! that locked them. In Pike any thread can unlock a locked mutex. - //! + /* Fallback implementation of Thread.Mutex */   class Mutex   {    static int locks = 0;    static void dec_locks() {locks--;}    -  //! @decl MutexKey lock() -  //! @decl MutexKey lock(int type) -  //! -  //! This function attempts to lock the mutex. If the mutex is already -  //! locked by a different thread the current thread will sleep until the -  //! mutex is unlocked. The value returned is the 'key' to the lock. When -  //! the key is destructed or has no more references the lock will -  //! automatically be unlocked. The key will also be destructed if the lock -  //! is destructed. -  //! -  //! The @[type] argument specifies what @[lock()] should do if the -  //! mutex is already locked by this thread: -  //! @integer -  //! @value 0 (default) -  //! Throw an error. -  //! @value 1 -  //! Sleep until the mutex is unlocked. Useful if some -  //! other thread will unlock it. -  //! @value 2 -  //! Return zero. This allows recursion within a locked region of -  //! code, but in conjunction with other locks it easily leads -  //! to unspecified locking order and therefore a risk for deadlocks. -  //! -  //! @seealso -  //! @[trylock()] -  //! +     MutexKey lock (int|void type)    {    switch (type) {
664:    return MutexKey (dec_locks);    }    -  //! @decl MutexKey trylock() -  //! @decl MutexKey trylock(int type) -  //! -  //! This function performs the same operation as @[lock()], but if the mutex -  //! is already locked, it will return zero instead of sleeping until it's -  //! unlocked. -  //! -  //! @seealso -  //! @[lock()] -  //! +     MutexKey trylock (int|void type)    {    switch (type) {