Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #120918

libwy-0.69.3 is released

From wij <wyniijj5@gmail.com>
Newsgroups comp.lang.c++
Subject libwy-0.69.3 is released
Date 2024-11-19 21:05 +0800
Organization A noiseless patient Spider
Message-ID <bda070a6eaad3e6c76ee6d026e5e5fdaf3ff138d.camel@gmail.com> (permalink)

Show all headers | View raw


libwy-0.69.3 is released.

https://sourceforge.net/projects/cscall/
An elementary C++ library by wrapping commonly used C library functions and
system calls into forms suitable for solving problems in fast and effective OO
way. The structure and API of this library are robust, almost fool-proof,
application normally just use it mechanically. This library added few for
developer to learn and remember in hopes that users can focus more on real
things, no need to endless learn things 'backwardly'.
------------------

This release added classes for forking process and memory mapping, because
the range of application of these two are much wider than threads (maybe safer
and easier, too). The following is an example program.

------------------------
/* Copyright is licensed by GNU LGPL, see file COPYING.       by I.J.Wang 2024

   Two proceeses increase one single int from 0 to 200 alternatively by using
   mmap,semaphore
*/
#include <Wy.stdio.h>
#include <Wy.unistd.h>
#include <Wy.semaphore.h>
#include <CSCall/MemMap.h>

using namespace Wy;

int *shared_nptr=NULL;
Semaphore sem(Semaphore::InProcess,1);

// [Syn] Increase $shared_nptr pointer int from 0 to 200 depending on whether
//       $v and the int are both odd, or even.
//
int ftask(int v) {
 Errno r;

 for(;;) {
   if((r=sem.wait())!=Ok) {
     WY_THROW(r);
   }
   if(*shared_nptr>200) {
     break;
   }
   if((*shared_nptr&1)!=v) {
     if((r=sem.post())!=Ok) {
       WY_THROW(r);
     }
     continue;
   }
   cout << (v? 'o':'e')  << *shared_nptr << ' ';
   ++*shared_nptr;
   if((r=sem.post())!=Ok) {
     WY_THROW(r);
   }
 }
 return v;
};

int main(int argc, const char* argv[])
try {
 Errno r;

 MemMap mmap(NULL,sizeof(int),PROT_READ|PROT_WRITE,MAP_SHARED);
 shared_nptr= static_cast<int*>(mmap.addr());

 *shared_nptr=0;

 ForkProcess fproc(ftask,1);  // run ftask(1) in a new process

 ftask(0);

 if((r=fproc.wait())!=Ok) {   // wait for change of state
   WY_THROW(r);
 }

 cout << WY_ENDL "OK" WY_ENDL;
 return 0;
}
catch(const Errno& e) {
 cerr << wrd(e) << WY_ENDL;
 return e.c_errno();
}
catch(...) {
 cerr << "main() caught(...)" WY_ENDL;
 throw;
};

Back to comp.lang.c++ | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-19 21:05 +0800
  Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-19 21:21 +0800
  Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-19 15:13 +0000
    Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-20 00:55 +0800
      Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-19 17:02 +0000
        Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-20 11:36 +0800
          Re: libwy-0.69.3 is released Bonita Montero <Bonita.Montero@gmail.com> - 2024-11-20 07:42 +0100
          Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-20 08:22 +0000
            Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-20 23:20 +0800
              Re: libwy-0.69.3 is released wij <wyniijj5@gmail.com> - 2024-11-21 00:17 +0800
                Re: libwy-0.69.3 is released "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 13:31 -0800
                Re: libwy-0.69.3 is released "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-11-20 13:32 -0800
              Re: libwy-0.69.3 is released Muttley@DastartdlyHQ.org - 2024-11-20 16:40 +0000

csiph-web